Click here to Skip to main content
13,055,861 members (50,461 online)
Rate this:
Please Sign up or sign in to vote.
I have created a user control.
<script type="text/javascript">
    function btnShowPopUp_Click() {
        return false;
    function btnCancel_Click() {
        return false;
    function btnOK_Click() {
        //I have to do some logic here but don't know
<asp:Button ID="btnHidden" runat="server" Style="display: none;" />
<asp:Button ID="btnShowPopUp" runat="server" OnClientClick="return btnShowPopUp_Click();"Text="Enter Number" />
<asp:UpdatePanel ID="updatePanel1" runat="server">
        <div style="background: #f8f8f8; border: solid 2px #080808; padding: 15px;">
            <asp:Label ID="lblNumber" Text="Number" runat="server" />
            <asp:TextBox ID="txtNumber" runat="server" />
            <br />
            <asp:Button ID="btnOK" runat="server" OnClientClick="return btnOK_Click();" Text="OK" />
            <asp:Button ID="btnCancel" runat="server" OnClientClick="return btnCancel_Click();"Text="Cancel" />
<asp:ModalPopupExtender ID="modalPopUp1" runat="server" BehaviorID="popUp" PopupControlID="updatePanel1"
    TargetControlID="btnHidden" />

And then added two properies in code behind.
<pre lang="c#"> private string _assLabel = "";
    public string AssociatedLabelID
            return _assLabel;
            _assLabel = value;
    private string _assTextBox = "";
    public string AssociatedTextBoxID
            return _assTextBox;
            _assTextBox = value;

<asp:Label ID="lblFirstNum" runat="server" Text="Enter First Number" />
        <asp:TextBox ID="txtFirstNum" runat="server" />
        <uc1:WebUserControl ID="wucFirst" AssociatedLabelID="lblFirstNum" AssociatedTextBoxID="txtFirstNum"  runat="server" />
        <br />
        <asp:Label ID="lblSecondNum" runat="server" Text="Enter Second Number" />
        <asp:TextBox ID="txtSecondNum" runat="server" />
        <uc1:WebUserControl ID="wucSecond" AssociatedLabelID="lblSecondNum" AssociatedTextBoxID="txtSecondNum"  runat="server" />

Now what I have to do is that when I first click 'wucFirst' it will show me PopUp which is in the user control.  When I enter some values in 'txtNumber' and click OK button I want to assign that value in AssociatedTextBoxID or if click 'wucSecond' and enter value in 'txtNumber' and click OK button I want to assign value in 'wucSecond's AssociatedTextBoxID.
Posted 1-Nov-12 18:58pm
ryanb31 2-Nov-12 16:40pm
If you want to get the property values in JavaScript you'll have to write them to a hidden field on the page. Then JS can have access to them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 2 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100