【问题标题】:code behind and postback in master page doesnt work母版页中的代码隐藏和回发不起作用
【发布时间】:2015-05-30 13:35:14
【问题描述】:

我有一个非常烦人的问题... 我的母版页中有一个文本框和一个链接。我想使用链接按钮将文本框的文本作为查询字符串传递给一些过滤的东西。
但我知道链接 bottun 后面的 cod 根本不起作用,它只是刷新页面。
我试图通过 window.location.href 的 jquery 来做到这一点,但它只在第一页有效,其他页面无法获得回发。
我改变了一切并尝试使用 radsearchbox。 此控件工作正常,但它只适用于除主页之外的每个页面。 让我更清楚:

http://kalashabakeh.ir/product.aspx?groupID=1&subgroupID=0 上效果很好

但它在www.kalashabakeh.ir不起作用

我真的不知道什么会引起这么多问题。也许是我的脚本管理器或 js 文件之类的?
请帮助我!

这是我当前使用 radsearchbox 的代码:
在 masterpage.master 中:

<telerik:RadSearchBox runat="server" ID="RadSearchBox2"
            CssClass="searchBox" Skin="Silk"
            Width="200" DropDownSettings-Height="300"
            DataSourceID="SqlDataSource_search"
            DataTextField="product_name"
            DataValueField="product_key"
            EmptyMessage="جستجو..."
            Filter="Contains"
            MaxResultCount="20"
            OnSearch="RadSearchBox2_Search">
</telerik:RadSearchBox>

在母版页代码隐藏中:

protected void RadSearchBox2_Search(object sender, SearchBoxEventArgs e)
{

       Response.Redirect("product.aspx?searchID="+ e.Text.ToString(),false);

}

【问题讨论】:

    标签: asp.net telerik scriptmanager


    【解决方案1】:

    是拼写错误还是类似的东西。您的 Rad 搜索框控件 ID 是 RadSearchBox2,它正在调用一个名为 RadSearchBox2_Search 的事件处理程序,而您有一个名为 RadSearchBox1_Search 的处理程序方法。见下文指出

    <telerik:RadSearchBox runat="server" ID="RadSearchBox2"
     .....
                OnSearch="RadSearchBox2_Search"> <--Here
    </telerik:RadSearchBox
    
    
    protected void RadSearchBox1_Search(object sender
                        ^-------- Here
    

    【讨论】:

    • 非常感谢您的回复,但这是我发布问题的错误。在我的代码中,我有 radsearchbox2_search。我现在已经编辑了帖子。感谢您的召回。
    • 您将其重定向到product.aspx。您确定这不是您的默认起始页(或)主页吗?您的主页名称是什么?
    • 我的主页是 Defualt.aspx
    【解决方案2】:

    我终于找到答案了... 正如人们所讨论的那样here
    它是iis7中的一种错误... 感谢 Eric
    ,这段代码解决了我的问题 只需在母版页中添加此代码。
    公共无效Page_PreRender(对象发送者,EventArgs e) { if (string.IsNullOrEmpty(this.Page.Form.Action) && Request.Url.AbsolutePath.ToLower().EndsWith("/default.aspx")) this.Page.Form.Action = "Default.aspx"; }
    现在我可以点亮我的 cigurate ...

    【讨论】:

      猜你喜欢
      • 2010-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多