Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refresh user control

Status
Not open for further replies.

slatetm

Programmer
Mar 20, 2007
16
US
I hope I am able to describe this clearly enough. I have an aspx page (View.aspx). I have a user control within that page that holds everything (View.ascx). One of the things it displays is a list of every comment that has been entered in the database for a particular object. Within the control View.ascx, is one more control (Add.ascx) for entering a new comment into the database.

After hitting the submit button on the add.ascx page, I want to refresh view.ascx so that the newly entered data will display. The problem is that view.ascx loads before the submit button click function runs on add.ascx.

I've tried a few different ways to get it to refresh but I have not been successful. Any suggestions would be appreciated. Thanks!
 
first off, this question would be better suited for the asp.net forum.

to answer your question:
[ol]
[li]create a public function in the ascx file called RefreshData(). within this function add all your data binding logic for comments.[/li]
[li]from within the user control call this function to bind data. example
Code:
protected void Page_Load(object sender, EventArgs e)
{
   if (!Page.IsPostback)
   {
        this.RefreshData();
   }
}
[/li]
[li]Now in the aspx code behind call this function in the button click event
Code:
protected void MyButton_Click(object sender, EventArgs e)
{
   if (Page.IsValid)
   {
       //save comment
       this.MyUserControl.RefreshData();
   }
}
[/li]
[/ol]

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top