showing null values in Server.Transfer

Posted by Kalyani under Regular Expressions on 4/15/2011 | Points: 10 | Views : 1860 | Status : [Member] | Replies : 3
HI,
when am using Server.Transfer in pasg1.aspx Button1_Click
string val = TextBox1.Text; string val1 = TextBox2.Text;
HttpContext _context = HttpContext.Current;
_context.Items.Add("val", val); _context.Items.Add("val1", val1);
Server.Transfer("page2.aspx");
in page2.aspx page load values r coming HttpContext _context = HttpContext.Current;HiddenField hd = new HiddenField();
HiddenField hd1 = new HiddenField();
if (!IsPostBack)
{
Response.Write(hf.Value);
if (_context.Items["val"] != null)
{
hd.Value = _context.Items["val"].ToString();
}
if (_context.Items["val1"] != null)
{
hd1.Value = _context.Items["val1"].ToString();
}

}
in button click values r not coming
Response.Write(hd.Value);
Response.Write(hd1.Value);




Responses

Posted by: Vuyiswamb on: 4/15/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
why do you use server.transer ? use a querystring and use response.redirect

Thank you for posting at Dotnetfunda
[Administrator]

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sutotpal on: 4/15/2011 [Member] Starter | Points: 25

Up
0
Down
hi,

becoz After button submit in Page2.aspx, your value of (_context.Items["val"] become null, so hd.Value ="" & hd1.Value ="" .

Best Regards,
Sutotpal

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kalyani on: 4/15/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Vuyiswamb ,
i know abt a querystring and response.redirect . am tesing server.transer.
i read one artical to Improving .NET Application Performance and Scalability server.transfer() instead of response.redirect().
And i don't want to show all querystring values to user. that's waht am implementing server.transfer() :)
Hi Sutotpal,
thanks for ur replay. yes that giveing null. hiow to get values ?

Regards
kalyani

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response