Arrao4u

…a blog by Rama Rao

Archive for the ‘Passing usercontrol textbox value to aspx page using delegate’ Category

Passing usercontrol textBox value to main page using delegate

Posted by arrao4u on April 24, 2011

create usercontrol webusercontrol3.ascx:

<

table><tr><td>My Name: <asp:TextBoxID=”txtName”runat=”Server”></asp:TextBox></td></tr><tr><td><asp:ButtonID=”Button1″runat=”server”OnClick=”Button1_Clicked”Text=”Send TextBox Value to the Page”/></td></tr></table

In the code behind of usercontrol

public

delegatevoidSendMessageToThePageHandler(string messageToThePage);publiceventSendMessageToThePageHandler sendMessageToThePage;

protectedvoid Page_Load(object sender, EventArgs e)

{

}

protectedvoid Button1_Clicked(object sender, EventArgs e) { if (sendMessageToThePage != null) { sendMessageToThePage(txtName.Text); } }

In th aspx apge

<

uc3:TestDelegateID=”ramafinaltest”runat=”server”

/>

<asp:LabelID=”lblUserControlTextBoxValue”runat=”Server”Font-Bold=”True”></asp:Label><hr/>

ramafinaltest.sendMessageToThePage +=

delegate(string message) { lblUserControlTextBoxValue.Text = message; };

Posted in Passing usercontrol textbox value to aspx page using delegate | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.