English 中文(简体)
在jQuery对话框中模拟另一个按钮回传
原标题:Simulate a another button postback inside a jQuery dialog

我有以下协会网页:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script src="js/jquery-1.2.6.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui-1.6.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {

            $("#dialog").dialog({
                bgiframe: true,
                autoOpen: false,
                height: 300,
                modal: true,
                buttons: {
                     Ok : function() {
                        $(this).dialog( close );
                        __doPostBack( TreeNew ,   );
                    },
                    Cancel: function() {
                        $(this).dialog( close );
                    }
                },
                close: function() {
                    ;
                }
            });
        });
        function ShowDialog() {
            $( #dialog ).dialog( open );
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="TreeNew" runat="server" Text="Nuevo" OnClientClick="ShowDialog(); return false;"/>
        <asp:Label ID="Message" runat="server"></asp:Label>
        <div id="dialog" title="Create new user">
            <p id="validateTips">All form fields are required.</p>
            <asp:RadioButtonList ID="ContentTypeList" runat="server">
                <asp:ListItem Value="1">Text</asp:ListItem>
                <asp:ListItem Value="2">Image</asp:ListItem>
                <asp:ListItem Value="3">Audio</asp:ListItem>
                <asp:ListItem Value="4">Video</asp:ListItem>
        </asp:RadioButtonList>
        </div>
    </div>
    </form>
</body>
</html>

当用户点击TreeNew按钮时,模态对话框将出现,然后他/她选择一个选项并单击确定按钮执行回传。

我需要服务器端执行TreeNew_Click方法:我该怎么做?

如果我使用__doPostBack(TreeNew,)它会抛出以下错误:“对象期望”。

UPDATE:
I found the origin for the error: the function __doPostBack is not defined. I m not going to delete the question because I think Chris Clark s answer is so interesting.

最佳回答

通常情况下,如果您发现自己在输入文本“__doPostBack(...”,您应该重新评估您的方法。

在这种情况下,你就应该把服务器的侧面作为服务器,然后把服务器放在 d子里,把它变成了方言,而不是制造 j子。 这样,退税法就会为你提供线索。 但是,有一席之地——当 j将 your四(假定 d四)变成了方言时,则将四舍五入到<>。 这意味着,你必须随行“BACK”号,以待退。 你可以在博客的密切职能中这样做。 然后,退后将适当发生。

如果您真的想使用生成的jQuery OK按钮,您有几个选项。首先,您可以在页面上放置一个服务器端的asp.net按钮并将其隐藏,然后从OK按钮的代码中调用asp.net按钮的点击事件。其次,您可以通过使用Page.ClientScript.GetPostBackEventReference从服务器发出一个JavaScript函数,该函数将包含您试图手写的__doPostBack代码。然后从OK按钮的JS代码中调用该发射函数。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!