how to get form values from referrer in asp.net web forms
in asp.net webforms is there a way to get the posted values of the previous page without having to send through query strings?
I want to pickup TxtSearch on the next page and I though I remember someway of doing without session or querystring (i thought you could you something like Request.Form开发者_运维知识库();)
<tr>
<td><asp:TextBox ID="TxtSearch" runat="server"></asp:TextBox></td>
<td><asp:LinkButton ID="BtnSearch" runat="server" onclick="BtnSearch_Click">Search</asp:LinkButton></td>
<td><asp:LinkButton ID="BtnShowAll" runat="server" onclick="BtnShowAll_Click">Show All Shelters</asp:LinkButton></td>
</tr>
</table>
enter code here
<asp:Button ID="button1" Runat=server Text="submit" PostBackUrl="~/NewPage.aspx" />
Then, in the NewPage.aspx.cs, you can access the TextBox control on Default.aspx as follows:-
public void page_load()
{
if(!IsPostBack)
{
TextBox tb = (TextBox)PreviousPage.FindControl("Text1");
Response.Write(tb.Text);}
}
If the values are posted you should be able to use Request and then your variable inside square brackets and quotes.
Try this from MSDN: How to Pass Values Between ASP.NET Web Pages.
An ASP.NET page posts to itself by default but you can post to a different page. See How to Post ASP.NET Web Pages to a Different Page and Cross-Page Posting in ASP.NET Web Pages.
var txtSearch = Request["TxtSearch"];
精彩评论