How to Refresh A User Control within a ASP.NET page

H

Hermit Dave

you can't... user control is rendered as a part of page... if you wish to
just have a particular area refresh. consider using iframe and instead of
user control having a dedicated aspx page which is wound to iframe using src
attribute. you can use the meta tag or client side event based refresh the
page within iframe.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 
G

Guest

Thanks, Dave.

What about use JavaScript to call PostBack on the control ? Will that work ?
 
Joined
Oct 12, 2007
Messages
1
Reaction score
0
Simply create a public method (example : public void refresh()) where you'll Bind the usercontrol's controls with Datas...
When you need to refresh the user Control call this method ! (in a event for example)

in user control :
public void refresh()
{
DropDownListUsers.DataSource=yourdatesource;
DropDownListUsers.DataBind();
}

And in your Page_Load (in UserControl) you'll have :
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
refresh();
}
}


In the page where you use your UserControl :
protected void ButtonValid_Click(object sender, EventArgs e)
{
YourUserControl1.refresh();
}
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top