Reputation: 119
In my code i added dynamically some text-boxes and labels.
Then by dropdownlist event i want to refresh the page in a way that all the added text-boxes and labels will remove from aspx
how can it be done?
Upvotes: 0
Views: 120
Reputation: 801
Add AutoPostBack="True"
for the DropDownList
Add an event to DropDownList for SelectedIndexChange
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
In the Code-Behind file :
private void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 0)
{
Label1.Visible = false;
}
else
{
Label2.Visible = false;
}
}
Upvotes: 0
Reputation: 2961
I assume you're using C#.
You can redirect to the current page by doing this from your code-behind:
Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
Upvotes: 1