How to get values of associated contrl's
I have created a web user control for numeric pad to enter numbers for touch screen application.
<asp:Panel ID="pnlPopUp" runat="server">
<table>
<tr>
<td>
<asp:Label ID="lblNumbers" runat="server" Text="Numbers:" />
</td>
<td>
<asp:TextBox ID="txtNumbers" runat="server" />
</td>
</tr>
<tr>
...rows for numeric buttons...
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnOK" OnClick="btnOK_Click" runat="server" Text="OK" />
<asp:Button ID="btnClose" runat="server" Text="Close" />
</td>
</tr>
</table>
</asp:Panel>
<asp:ModalPopupExtender ID="popupPnl" runat="server" DynamicServicePath="" Enabled="True" TargetControlID="btnShow" CancelControlID="btnClose" PopupControlID="pnlPopUp">
</asp:ModalPopupExtender>
And created a method to show popUp, an event to get Ok button click event and a property to get entered text.
public void ShowPopUp()
{
popupPnl.Show();
}
string textBoxValue = "";
public string txtValue
{
get
{
return textBoxValue;
}
}
public event EventHandler OKButtonClick;
public void btnOK_Click(object sender, EventArgs e)
{
textBoxValue = txtNumbers.Text;
OKButtonClick(sender, e);
txtNumbers.Text = "";
}
And then added an aspx page and register the userControl
Numbers:
<asp:TextBox ID="txtNum" runat="server" />
<asp:Button ID="button1" runat="server" Text="Show" OnClick="button1_Click" />
<br />
Numbers2:
<asp:TextBox ID="txtNum2" runat="server" />
<asp:Button ID="button2" runat="server" Text="Show" OnClick="button1_Click" />
<uc1:WebUserControl ID="popUp" runat="server" />
aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
popUp.OKButtonClick += new EventHandler(Ok_Click);
}
protected void button1_Click(object sender, EventArgs e)
{
popUp.ShowPopUp();
}
protected void Ok_Click(object sender, EventArgs e)
{
txtNum.Text = popUp.txtValue;
}
It's working fine. Now when I click the button1 I want to add values of TextBox of popUp control's in txtNum or I click the button2 then I want to add values of TextBox of popUp control's in txtNum2 after clicking the btnOK of popUp control.