无法从代码隐藏获取 asp.net 文本字段
我在 aspx 页面中有一个小表单。该表单在 jQuery 对话框中呈现。我在此对话框中放置了两个按钮(jQuery 按钮)。由于这些不是 aspx 按钮,当按下 jQuery 对话框按钮时,我必须手动执行回发,如下所示:
对话框:
jQuery(function () {
var dlg = $('#dialog_renombrar').dialog({
autoOpen: false,
resizable: false,
modal: true,
width: 360,
buttons: {
"Aceptar": function () {
__doPostBack('rnmbrFchr', null);
},
"Cancelar": function () {
$(this).dialog("close");
}
}
});
表单:
<div
align="center"
id="dialog_renombrar"
style="padding: 10px 10px 10px 10px;
margin: 10px 10px 10px 10px;
width:100%;
height:100%;
display:none;
overflow:auto">
<table
cellspacing="2"
width="100%"
align="center">
<tr>
<td>
Documento:
</td>
<td>
<asp:TextBox
ID="nombre_antiguo"
Enabled="false"
style="width:100%;"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Nuevo nombre:
</td>
<td>
<cc1:SWCTextBox
ID="SWCTextBox3"
MarcarObligatorio="true"
style="width:100%; height:90%"
runat="server"></cc1:SWCTextBox>
<asp:HiddenField runat="server" ID="itemkey" />
</td>
</tr>
</table>
</div>
然后在执行回发时的代码隐藏中,我无法访问文本字段。不能做:
Request.Forms["SWCTextField3"]
值和即时对象都不可见。
我需要帮助。谢谢。
I have a small form in an aspx page. This form is rendered within a jQuery dialog. I put two buttons (jQuery buttons) within this dialog. Due those are not an aspx buttons I had to do the postback manually when a jQuery dialog button is pressed, like this:
The dialog:
jQuery(function () {
var dlg = $('#dialog_renombrar').dialog({
autoOpen: false,
resizable: false,
modal: true,
width: 360,
buttons: {
"Aceptar": function () {
__doPostBack('rnmbrFchr', null);
},
"Cancelar": function () {
$(this).dialog("close");
}
}
});
The form:
<div
align="center"
id="dialog_renombrar"
style="padding: 10px 10px 10px 10px;
margin: 10px 10px 10px 10px;
width:100%;
height:100%;
display:none;
overflow:auto">
<table
cellspacing="2"
width="100%"
align="center">
<tr>
<td>
Documento:
</td>
<td>
<asp:TextBox
ID="nombre_antiguo"
Enabled="false"
style="width:100%;"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Nuevo nombre:
</td>
<td>
<cc1:SWCTextBox
ID="SWCTextBox3"
MarcarObligatorio="true"
style="width:100%; height:90%"
runat="server"></cc1:SWCTextBox>
<asp:HiddenField runat="server" ID="itemkey" />
</td>
</tr>
</table>
</div>
Then in the codebehind when postback is performed I can't acces a textfield. Can't do:
Request.Forms["SWCTextField3"]
Neither the value nor the instant object are visible.
I need help. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过在提供页面源时查看文本框的实际 ID。默认情况下,ASP.NET 将修改页面上的 ID 以确保它们保持唯一。如果您使用的是 .NET 4,则可以通过设置页面指令
ClientIDMode="Static"
来覆盖此行为。Check the actual ID of the textbox by looking at the page source when it's served up. By default ASP.NET will mangle the IDs on the page to ensure they remain unique. If you're using .NET 4 then you can override this behaviour by setting the page directive
ClientIDMode="Static"
.如果回发是必须的,也许您可以将文本框内容附加为 URL 的查询字符串参数?
If postback is a must, perhaps you could tack-on the textbox contents as a querystring parameter of the URL?