Hello guys I hope you can help with an issue I can't figure out, thanks in advance.
The problem I'm having is with a textbox that apparently loses it's value when postbacked ,the situation is the following:
The form is used for a catalog, It has a gridview that displays the entries in the database, inside the gridview I have a linkbutton that is used as the edit button, when the user clicks it, it fills a textbox(inside an invisible div at this moment) with
the value from the database for the chosen item in the grid and after that it displays the div as a modal using jquery, I do this jquery script call from server side. The C# code is the following:
/*here i just get the database values ,fill a label and the textbox with them( it works fine)*/
/*Here i insert the jquery code to open the modal (apparently works fine)*/
Page.RegisterStartupScript("", "<script language=JavaScript>$(\".modalUp\").overlay({ top: 50, mask: { color: '#fff',loadSpeed: 200,opacity: 0.5}, closeOnClick: false, load: true});</script>");
At this point everything is apparently working fine, but when I change the text inside the textbox then click the update button(BtnUpdate) it goes to the click event and whenever I try to retrieve the value from the textbox it is always blank "" value. Also
I fill a label with some values from the database and it keeps the value.
I use this modal technique for inserting items in this same aspx and that part is working fine, I can't figure out what can be the problem I would really appreciate your help.
Never mind guys , I just moved the content to a different div and it started working, I really don't know what was the problem with this issue, perhaps some strange bug.
Marked as answer by Darkestnight on Oct 27, 2011 10:10 PM
Darkestnight
Member
4 Points
6 Posts
Problem with textbox value inside a modal.
Oct 27, 2011 09:37 PM|LINK
Hello guys I hope you can help with an issue I can't figure out, thanks in advance.
The problem I'm having is with a textbox that apparently loses it's value when postbacked ,the situation is the following:
The form is used for a catalog, It has a gridview that displays the entries in the database, inside the gridview I have a linkbutton that is used as the edit button, when the user clicks it, it fills a textbox(inside an invisible div at this moment) with the value from the database for the chosen item in the grid and after that it displays the div as a modal using jquery, I do this jquery script call from server side. The C# code is the following:
/*here i just get the database values ,fill a label and the textbox with them( it works fine)*/
string[] ArrayResult;
IDObject= Convert.ToInt32(GrvTipoObjeto.DataKeys[e.NewEditIndex].Value);
CatalogBusiness.GetObjectData(IDObject , out ArrayResult);
txtNomTipEdit.Text = ArrayResult[0];
lbIDType.Text = ArrayResult[1];
/*Here i insert the jquery code to open the modal (apparently works fine)*/
Page.RegisterStartupScript("", "<script language=JavaScript>$(\".modalUp\").overlay({ top: 50, mask: { color: '#fff',loadSpeed: 200,opacity: 0.5}, closeOnClick: false, load: true});</script>");
the aspx code is the following
<div class="modalUp" style="z-index: 2;">
<h2>
<span>Update Object</span></h2>
<br />
<br />
<form>
<table>
<tr>
<td>
Object Name<span style="color: Blue">*</span></td>
<td>
<asp:Label runat="server" ID="lbIDType" CssClass="Hide"></asp:Label>
</td>
<tr>
<td>New name:</td>
<td><asp:TextBox runat="server" ID="txtNomTipEdit" ValidationGroup="NewObj1"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ID="RfvtxtNomTipEdit" ControlToValidate="txtNombreObjeto"
ValidationGroup="NewObj1"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
<br />
<br />
<table>
<tr>
<td>
<asp:LinkButton runat="server" ID="BtnUpdate" Text="Actualizar" CssClass="btnUpdate"
OnClick="BtnUpdate_OnClick" ValidationGroup="NewObj1"></asp:LinkButton>
</td>
<td>
<button type="button" class="close">
Cancelar
</button>
</td>
</tr>
</table>
</form>
<br />
</div>
At this point everything is apparently working fine, but when I change the text inside the textbox then click the update button(BtnUpdate) it goes to the click event and whenever I try to retrieve the value from the textbox it is always blank "" value. Also I fill a label with some values from the database and it keeps the value.
I use this modal technique for inserting items in this same aspx and that part is working fine, I can't figure out what can be the problem I would really appreciate your help.
Darkestnight
Member
4 Points
6 Posts
Re: Problem with textbox value inside a modal.
Oct 27, 2011 10:09 PM|LINK
Never mind guys , I just moved the content to a different div and it started working, I really don't know what was the problem with this issue, perhaps some strange bug.