Jquery css在asp.net c#的更新面板中不起作用 [英] Jquery css not working in update panel in asp.net c#

查看:110
本文介绍了Jquery css在asp.net c#的更新面板中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<body>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

    <link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"

        rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>

    <link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"

        rel="stylesheet" type="text/css" />

    <script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js"

        type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            $('#<%= lstFruits.ClientID %>').multiselect({
                includeSelectAllOption: true
            });
        });
    </script>

    <form id="form1"  runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <contenttemplate>
            <asp:ListBox ID="lstFruits" runat="server" SelectionMode="Multiple">
                <asp:ListItem Text="Mango" />
                <asp:ListItem Text="Apple" />
                <asp:ListItem Text="Banana" />
                <asp:ListItem Text="Guava" />
                <asp:ListItem Text="Orange" />
            
        </contenttemplate>
    
    <asp:Button ID="Button1" Text="Submit" runat="server" OnClick="Submit" />
    </form>
</body>





CS代码:



CS Code :

protected void Submit(object sender, EventArgs e)
    {

        string message = "";
        foreach (ListItem item in lstFruits.Items)
        {
            if (item.Selected)
            {
                message += item.Text + ",";
            }
        }
        message = message.Substring(0, message.Length - 1);
        ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "a", "alert('" + message + "')", true);

    }





从上面的代码我把按钮放在更新面板上然后它正常工作。

当我放入更新面板时,

当提交按钮时,从下一个请求下拉看起来像列表框。



你能帮我解决这个问题。



有没有可能/我会继续这样做。



请复制代码并尝试获得更多说明。



谢谢



对我来说非常重要。



From above code i placed button out from update panel then it working fine.
When i placed inside update panel,
When submit button, then drop down looking like list box from next request.

Can you please help me to come out from this issue.

Is there any possibility / shall i continue the same.

Please copy the code and try you can get more clarification.

Thanks

Its very important to me.

推荐答案

function (){

' #<%= lstFruits.ClientID%>')。multiselect( {
includeSelectAllOption: true
});
});
< / script >

< 表格 id = form1 runat = server >
< asp:ToolkitScriptManager ID = ToolkitScriptManager1 runat = 服务器 >

< asp:UpdatePanel ID = UpdatePanel1 runat = server >
< < span class =code-leadattribute> contenttemplate
>
< asp:ListBox ID = lstFruits runat = server SelectionMode = 多个 >
< asp:ListItem 文字 = 芒果 / >
< asp:ListItem 文本 = Apple / >
< asp:ListItem 文字 = 香蕉 / >
< asp:ListItem 文本 < span class =code-keyword> = 番石榴 / >
< asp:ListItem 文字 = 橙色 / >

< span class =code-keyword>< / contenttemplate >

< asp:按钮 ID = Button1 < span class =code-attribute> 文本 = 提交 runat = server OnClick = 提交 / >
< / form >
< / body >
('#<%= lstFruits.ClientID %>').multiselect({ includeSelectAllOption: true }); }); </script> <form id="form1" runat="server"> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <contenttemplate> <asp:ListBox ID="lstFruits" runat="server" SelectionMode="Multiple"> <asp:ListItem Text="Mango" /> <asp:ListItem Text="Apple" /> <asp:ListItem Text="Banana" /> <asp:ListItem Text="Guava" /> <asp:ListItem Text="Orange" /> </contenttemplate> <asp:Button ID="Button1" Text="Submit" runat="server" OnClick="Submit" /> </form> </body>





CS代码:



CS Code :

protected void Submit(object sender, EventArgs e)
    {

        string message = "";
        foreach (ListItem item in lstFruits.Items)
        {
            if (item.Selected)
            {
                message += item.Text + ",";
            }
        }
        message = message.Substring(0, message.Length - 1);
        ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "a", "alert('" + message + "')", true);

    }





从上面的代码我把按钮放在更新面板上然后它正常工作。

当我放入更新面板时,

当提交按钮时,从下一个请求下拉看起来像列表框。



你能帮我解决这个问题。



有没有可能/我会继续这样做。



请复制代码并尝试获得更多说明。



谢谢



对我来说非常重要。



From above code i placed button out from update panel then it working fine.
When i placed inside update panel,
When submit button, then drop down looking like list box from next request.

Can you please help me to come out from this issue.

Is there any possibility / shall i continue the same.

Please copy the code and try you can get more clarification.

Thanks

Its very important to me.


声明一个更新触发器并在其中包含按钮
declare an update trigger and include button into it


这篇关于Jquery css在asp.net c#的更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆