Solved

reading textbox value from user control in ajax modal popup extnder

Posted on 2014-09-03
6
906 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 M
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now