asp.net - Getting TextBox's Text on Next Page if Visible is false (Cross-Page Postback) -
i have aspx page contains 2 tables (each textbox controls in it).
when page first rendered, first table shown (second table's visible
property set false
). user fills out textboxes , clicks continue button.
now, first table's visible = false;
, second table's visible = true;
, user fills out second table.
submit button clicked. postbackurl
of button set new page in i'm trying , display entered in last page using request.form["ctrlname"];
the problem is... first table's visibility set false server never rendered it. shouldn't data still in viewstate? how retrieve data first table not rendered?
obviously cant use request.form["table1ctrlname"];
data textbox in table1, isn't there way of querying incoming viewstate directly data?
you can use previouspage
property on next page.
example:
page-1 (aspx):
<asp:panel id="pnl1" runat="server"> first text box: <asp:textbox id="txt1" runat="server"></asp:textbox> </asp:panel> <asp:panel id="pnl2" runat="server" visible="false"> second text box: <asp:textbox id="txt2" runat="server"></asp:textbox> </asp:panel> <asp:button id="btnnext" runat="server" onclick="btnnext_click" text="next" /> <asp:button id="btnsubmit" runat="server" text="submit" postbackurl="~/page2.aspx" />
page-1 (code):
protected void btnnext_click(object sender, eventargs e) { this.pnl1.visible = false; this.pnl2.visible = true; }
page-2 (code):
protected void page_load(object sender, eventargs e) { if (this.ispostback) { var svalue1 = ((textbox)this.previouspage.findcontrol("txt1")).text; var svalue2 = ((textbox)this.previouspage.findcontrol("txt2")).text; console.writeline(svalue1); console.writeline(svalue2); } }
for details, see cross-page posting in asp.net web pages
Comments
Post a Comment