C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

Communication between User controls.


Posted Date: 07 Jan 2009    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: Anila RMember Level: Bronze    
Rating: 1 out of 5Points: 10



Asp.Net page contain two user controls. We need to update/refresh Second user control while changing the first user control and vice versa without refreshing the page.

For that we need to add update panel inside the user control and create a public method in each user controls for updating the user controls

Functions


public void ReloadNote()
{
this.ButtonReload_Click(this,new EventArgs());
NotesPanel.Update(); // panel inside user control is updating
}


while updating any of this user controls we need to call a common Javascript function. From Javascript we need to invoke parent page button click event. This button is needed to put inside an update panel and also need to make that button style hidden

like



<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnReloadNoteTask" runat="server" style="visibility:hidden;" Text="Button"
OnClick="btnReloadNoteTask_Click" />
</ContentTemplate>
</asp:UpdatePanel>


Javascript Functions


function ReloadTaskEvent()
{
__doPostBack('btnReloadNoteTask', '');

}


server side click event will call the public methods of user controls

click event of btnReloadNoteTask button



protected void btnReloadNoteTask_Click(object sender, EventArgs e)
{
NoteControl.ReloadNote(); //first user control public method call
UpcomingHistoryControl.ReloadpcomingHistory(); //second user control public method call
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Happy coding  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Popwin control complete solution in asp.net
Previous Resource: Paging in DataList
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use