Solved

reading textbox value from user control in ajax modal popup extnder

Posted on 2014-09-03
6
1,017 Views
Last Modified: 2014-10-24
Parent .aspx Form has 5 buttons. Each opens a ajax modal pop-up extender containing a user control (.uscx).
The uscx is registered, all works well.

Button opening  the modal is  below. The 5 buttons are in sequence  BtnDims1, BtnDims2  etc.  So are all the ID's


 
<asp:Button ID="BtnDims1" runat="server" Text="Dim" Width="31px" Font-Size="XX-Small" ToolTip="Enter Dimensional Load Information" TabIndex="11" />
                        <ajax:ModalPopupExtender ID="BtnDims1_Mpe" runat="server"  Enabled="True" TargetControlID="BtnDims1" PopupControlID="PNLfgtDimension1"   DropShadow="true">
                        </ajax:ModalPopupExtender>
                       <asp:Panel ID="PNLfgtDimension1"  style="display:none;"   runat="server" BorderColor="#212020" BorderStyle="Double" Visible="true" BorderWidth="6px" Width="440px" Height="150px" BackColor="White">
                        <uc1:FgtDemensions runat="server" ID="FgtDimensions1" />
                      </asp:Panel>

Open in new window

The user control has 3 text boxes (TBlength, TBWidth & TBHeight) and one cmd buttom.

After client enters the 3 values  they click the save button, things are saved and the modal closes.  
Now I want to be able to read the values from those text boxes from the parent page.(I know the inputs are still there because when I click on the modal popup button again the inputs still display.)

I can find the main child controls (the panels and forms)  in the control collection but can not successfully get the values from the text boxes.  
I found the user control using this code.
MyModal1 = CType(FindControl("BtnDims1_Mpe"), AjaxControlToolkit.ModalPopupExtender)
Dim fgtcontrol As UserControl = CType(MyModal1.FindControl("FgtDemensions1"), UserControl)

Can someone show me how to read the textboxes?     I know hoe to send vales from a child.
Not having any success at reading (pulling) from a child.

Thanks!
0
Comment
Question by:ash691
6 Comments
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 40303269
You can save it in the session when they click submit.

Session("height") = btnDims.text

.. Then read the value back on the main form.  Make sure you clear the values after using them.

Dim theheight as string = Session("height")
Session("height") = ""
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 40303336
If you use the developer tool in the browser you can track the hierarchy of the controls in your modal popup.
then you can try finding them using .FindControl(). But it will be bit complex.

Best way is to store that values in session or in the viewstate.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40303398
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>

attach an event to your button in your modal popup :

$("#<%= Close.ClientID %>").click(function() {
      $.cookie("TextBox1inModal", $("#<%= TextBox1.ClientID").val() );
      $.cookie("TextBox2inModal", $("#<%= TextBox2.ClientID").val() );
});

Open in new window


Now in your parent page, you can read teh value by reading the cookies :
$.cookie("TextBox1inModal");
and :
$.cookie("TextBox2inModal");
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question