Hi all,
I am beginner learning ASP.NET with C# as the programming language.
Currently I am working with HTTPSERVERUTILITY.
I have created a web form named as Default.aspx and Default2.aspx:
I have written the following coding :
Default.aspx:
In source view
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
</form>
</body>
In Code-behind file:
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("Default2.aspx ? name =roseline & password = pass@123");
}
Coding for Default2.aspx:
In Source View:
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Text ="A"></asp:TextBox>
<br />
<br />
<asp:TextBox ID="TextBox2" runat="server" Text = "B"></asp:TextBox>
<br />
<br />
<asp:Button ID = "Button1" runat ="server" Text = "Button1" onclick="Button1_Click" />
<br />
</div>
</form>
</body>
In Code-Behind File:
public string n, p;
protected void Page_Load(object sender, EventArgs e)
{
n = Request.QueryString["name"];
p = Request.QueryString["password"];
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = n;
TextBox2.Text = p;
}
When I execute the above application I am not getting any error.
When I click on the Button1 in Default.aspx it shows me the Default2.aspx, but when I click on the button I am not getting the values in the TextBox.
Can anyone tell me what is wrong with my coding? Why it is not displaying the values in the TextBoxes?
Please help me out!
Thanks in advance!