Can't get asp.net textfield from codebehind
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 ar开发者_运维问答e visible.
I need help. Thank you.
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"
.
If postback is a must, perhaps you could tack-on the textbox contents as a querystring parameter of the URL?
精彩评论