Hi
I have a custom control that contains a DropDownList and a Button control and a "Datasource" and a "URL" property.
What this control do is to get the Datasouce (of DataSet type) and bind it to DropDownList and add an attribute to the button to open a popup window with the given URL.
In my web from I used this control inside an UpodatePanel .The problem is when I change the "URL" dinamically in my program,the previous value still remains in the button's attribute and still opens the same popup window.I added the attribute to button in OnPreRender method.Without an updatepanel it works fine.Here is some parts of code:
public DataSet DataSource
{
set
{
EnsureChildControls();
if (this.SelectedValue.Equals(String.Empty))
this.SelectedValue = null;
if (value != null)
{
drpOptions.Items.Clear();
drpOptions.DataBind();
drpOptions.DataSource = (
DataSet)value;
drpOptions.DataBind();
else
{
drpOptions.Items.Clear();
drpOptions.DataBind();
}
}
public string TargetUrl
{
set
{
this.targetUrl = value;
if (Page != null)
Page.RegisterHiddenField(
"__hiddenTargetUrl_" + this.ClientID, value);
}
get
{
if (Page.Request.Form["__hiddenTargetUrl_" + this.ClientID] != null && Page.Request.Form["__hiddenTargetUrl_" + this.ClientID] != "")
return Page.Request.Form["__hiddenTargetUrl_" + this.ClientID];
else
return this.targetUrl;
}
}
protected override void OnPreRender(EventArgs e)
{
btnPopUp.Visible = this.ButtonVisible;
if (this.Enabled)
{
btnPopUp.Attributes.Remove("onClick");
btnPopUp.Attributes.Add("onClick", "ShowDialog" + this.ClientID + "();return false;");
}
else
{
btnPopUp.Attributes.Remove(
"onClick");
btnPopUp.Attributes.Add(
"onClick", "return false;");
}
}