开发者

postback via MasterPage - ASP.Net, c#

I have a master page and have included a search text box.

User is on default.aspx

user enters a search value in the search text box, which is part of master page.

Via javascript the form, in MP, is submitted to my search functionality page, search.aspx and the code behind search.aspx.cs obtains the form post and gets the data.

Search.aspx has a bare bone table to display the results.

I have a breakpoint in search.aspx.cs and am able to see the raw results returned from DB. However after al开发者_Python百科l databinding has occured, the user is not directed from default.aspx to search.aspx


Don't use any javascript to submit the form, just set the PostBackUrl property of your search button to Search.aspx:

<asp:TextBox ID="TxtSearch" runat="server" />
<asp:LinkButton 
    ID="BtnSearch" 
    runat="server" 
    PostBackUrl="Search.aspx" 
    Text="Search" />

And in the Page_Load of Search.aspx read the posted value:

protected void Page_Load(object sender, EventArgs e)
{
    string searchText = Request["TxtSearch"];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜