how to use session to passing values between page c# ASP.NET web Forms -
i'm newbie in c# web api , want pass values between pages using session
.
here code.
page1.aspx
<asp:label id="lb_front" runat="server"></asp:label> <asp:textbox id="txt1" runat="server"></asp:textbox> <asp:button id="bt1" runat="server" onclick="bt1_click" />
page1.aspx.cs
protected void bt1_click(object sender, eventargs e) { lb_front.text = txt1.text; session["user"] = txt1.text; }
page2.aspx
<asp:label id="lb_top" runat="server"></asp:label>
page2.aspx.cs
protected void page_load(object sender, eventargs e) { lb_top.text = "<img src='./images_top/'"+ session["user"]+"'.jpg'></img>"; lb_top.text += session["user"]; }
i want use session value in path display image on label, isn't working.
you have set image path dynamically like:
page2.aspx
<asp:image runat="server" id="image" /> <asp:label id="lb_top" runat="server"></asp:label>
page2.aspx.cs
protected void page_load(object sender, eventargs e) { string sessionvalue = (string)session["user"]; image.imageurl = "../images_top/"+ sessionvalue +".jpg"; // set image url/src session lb_top.text += sessionvalue; }
Comments
Post a Comment