Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3914
  • Last Modified:

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
0
joeylu
Asked:
joeylu
  • 3
  • 3
1 Solution
 
tdotCommented:
Can we see the code
0
 
joeyluAuthor Commented:
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"></script>
    <script src="style/jquery.fancybox-1.3.1.pack.js" type="text/javascript"></script>
    <link href="style/jquery.fancybox-1.3.1.css" 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="CategoryAdmin" 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"
                OldValuesParameterFormatString="original_{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?
0
 
yogi4lifeCommented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
joeyluAuthor Commented:
my ugly solution is to make a control hidden outside of the modal div, and use javascript to pass the textbox(inside of the formview) value to that control, then retrieve the value from the formview inserting event.
well, it's way to complicate and ugly, there has to be an easy solution for this

one answer i've found online is that when the modal popup enabled (not only fancybox, any ajax modal control), the textbox value was misleading to the parent page instead of current page, could that be a case?
0
 
yogi4lifeCommented:
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...
0
 
joeyluAuthor Commented:
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
0
 
yogi4lifeCommented:
I am sorry but I don't have any suggestion for an elegant solution for this...
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now