joeylu
asked on
Textbox lost its value in postback in Modal Popups
I use the inline option for a fancybox, which is a jquery modal popup
in the modal inline div, I have a asp.net formview
everything works fine except the formview insert mode.
I have one textbox inside of formview(insert mode)
the textbox will lose its value whenever I click the "insert button"
if i disable the modal script, the problem will go away
any idea?
tks
in the modal inline div, I have a asp.net formview
everything works fine except the formview insert mode.
I have one textbox inside of formview(insert mode)
the textbox will lose its value whenever I click the "insert button"
if i disable the modal script, the problem will go away
any idea?
tks
Can we see the code
ASKER
i shrink the code a bit, basically it looks like this
I use the fancybox as modal popup and jquery framework at head
I use the masterpage
<script src="style/jquery.min.js" type="text/javascript"></s cript>
<script src="style/jquery.fancybox -1.3.1.pac k.js" type="text/javascript"></s cript>
<link href="style/jquery.fancybo x-1.3.1.cs s" rel="stylesheet" type="text/css" />
now in the content placeholder: I have a fancybox modal popup trigger, and i have a formview bind with objectdatasource, and a textbox, a button inside of the formview
<asp:Content ID="Content1" ContentPlaceHolderID="Cate goryAdmin" Runat="Server">
<a href="#data">Fancybox trigger</a>
<div id="#data">
<asp:FormView ID="FormView1" runat="server" DataKeyNames="sID" DataSourceID="ODS_123">
<InsertItemTemplate>
<asp:TextBox ID="TextBox" runat="server" Text='<%# Bind("content") %>' />
<asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" />
</InsertItemTemplate>
</asp:FormView>
<asp:ObjectDataSource ID="ODS_123" runat="server" InsertMethod="Insert"
OldValuesParameterFormatSt ring="orig inal_{0}" SelectMethod="GetAll"
TypeName="TableAdapter">
<InsertParameters>
<asp:Parameter Name="sID" Type="Int32" />
<asp:Parameter Name="content" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
</div>
</asp:Content>
It works perfectly fine if the formview is outside of that modal popup DIV, but within that DIV, it can't pass any value of that TextBox, always become Null when I click the insert button
any idea?
I use the fancybox as modal popup and jquery framework at head
I use the masterpage
<script src="style/jquery.min.js" type="text/javascript"></s
<script src="style/jquery.fancybox
<link href="style/jquery.fancybo
now in the content placeholder: I have a fancybox modal popup trigger, and i have a formview bind with objectdatasource, and a textbox, a button inside of the formview
<asp:Content ID="Content1" ContentPlaceHolderID="Cate
<a href="#data">Fancybox trigger</a>
<div id="#data">
<asp:FormView ID="FormView1" runat="server" DataKeyNames="sID" DataSourceID="ODS_123">
<InsertItemTemplate>
<asp:TextBox ID="TextBox" runat="server" Text='<%# Bind("content") %>' />
<asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" />
</InsertItemTemplate>
</asp:FormView>
<asp:ObjectDataSource ID="ODS_123" runat="server" InsertMethod="Insert"
OldValuesParameterFormatSt
TypeName="TableAdapter">
<InsertParameters>
<asp:Parameter Name="sID" Type="Int32" />
<asp:Parameter Name="content" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
</div>
</asp:Content>
It works perfectly fine if the formview is outside of that modal popup DIV, but within that DIV, it can't pass any value of that TextBox, always become Null when I click the insert button
any idea?
ASP.NET has the VIEWSTATE to communicate between client-side form and the server-side code...
Most likely in fancybox nothing with the viewstate is disrupted and information gets passed correctly.
But - when turning on modal fancybox is doing something more "fancy" so the manipulated form field looses connection with the viewstate and hence the server-side code doesnt get anything passed... it looses content...
You will have to inspect your real HTML (HTML source in the browser) running both with and without modal turned on.
Then you will have too look for how the form field is wrapped before it is submitted. That should give you a clue.
Most likely in fancybox nothing with the viewstate is disrupted and information gets passed correctly.
But - when turning on modal fancybox is doing something more "fancy" so the manipulated form field looses connection with the viewstate and hence the server-side code doesnt get anything passed... it looses content...
You will have to inspect your real HTML (HTML source in the browser) running both with and without modal turned on.
Then you will have too look for how the form field is wrapped before it is submitted. That should give you a clue.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you have any idea if the modal box might not be a child element of the form? If so some code to move it into the form might do the trick...
ASKER
I use master page
The content page structure looks like this:
Content
div for modal
Formview
Textbox
/Formview
/div
/content
This Textbox will not pass the value in formview insert event
however, if I pass this Textbox value to an outside Textbox, and retrive its value at insert event, it works
Content
textbox hidden
div for modal
Formview
Textbox
/Formview
/div
/content
The content page structure looks like this:
Content
div for modal
Formview
Textbox
/Formview
/div
/content
This Textbox will not pass the value in formview insert event
however, if I pass this Textbox value to an outside Textbox, and retrive its value at insert event, it works
Content
textbox hidden
div for modal
Formview
Textbox
/Formview
/div
/content
I am sorry but I don't have any suggestion for an elegant solution for this...