jQuery 带文本输入的模态消息
jQuery modal message with text input
我正在尝试通过添加 asp:Textbox 来编辑 jQuery 模态消息框。
用户点击Button1后,出现对话框,提示用户输入一个QtyRun(double)。最后他们按下 Enter。
如何将对话框中的用户输入传递给 aspx 表单上的变量或传递给 aspx 控件(如标签)?
这是我的脚本和 aspx 代码:
<script> $(function() {
$('#Button1').click(function() {
$("#dialog-message").dialog({
modal: true,
buttons: {
Enter: function () {
$('<%= Label1.Text %>').val($('<%= qtyRunText.Text %>').val());
$(this).dialog("close");
}}});
})
});
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<div id="dialog-message" title="Roll# Found!" style="display:none">
<p>
Enter QtyRun: <asp:TextBox ID="qtyRunText" runat="server"></asp:TextBox>
</p>
</div>
</form>
第一个问题是为什么在服务器控件中需要这些值。
但是,您可以按照以下方式进行操作:
您需要 asp 控件的 ID:
Enter: function () {
$('#<%=Label1.ID%>').val($('#<%=qtyRunText.ID%>').val());
$(this).dialog("close");
}}});
如果在服务器端设置这些 ID 属性会更友好:
Label1.ID = "asp_mylabel";
qtyRunText.ID = "asp_QtyRunText";
在 javascript 你可以调用 $('#asp_mylabel')
和 $('#asp_QtyRunText')
我正在尝试通过添加 asp:Textbox 来编辑 jQuery 模态消息框。 用户点击Button1后,出现对话框,提示用户输入一个QtyRun(double)。最后他们按下 Enter。
如何将对话框中的用户输入传递给 aspx 表单上的变量或传递给 aspx 控件(如标签)?
这是我的脚本和 aspx 代码:
<script> $(function() {
$('#Button1').click(function() {
$("#dialog-message").dialog({
modal: true,
buttons: {
Enter: function () {
$('<%= Label1.Text %>').val($('<%= qtyRunText.Text %>').val());
$(this).dialog("close");
}}});
})
});
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<div id="dialog-message" title="Roll# Found!" style="display:none">
<p>
Enter QtyRun: <asp:TextBox ID="qtyRunText" runat="server"></asp:TextBox>
</p>
</div>
</form>
第一个问题是为什么在服务器控件中需要这些值。
但是,您可以按照以下方式进行操作:
您需要 asp 控件的 ID:
Enter: function () {
$('#<%=Label1.ID%>').val($('#<%=qtyRunText.ID%>').val());
$(this).dialog("close");
}}});
如果在服务器端设置这些 ID 属性会更友好:
Label1.ID = "asp_mylabel";
qtyRunText.ID = "asp_QtyRunText";
在 javascript 你可以调用 $('#asp_mylabel')
和 $('#asp_QtyRunText')