I'm trying to find what could be the problem. I'm playing with Textbox watermark extender and it works great, but when I tried using other extenders to same targetcontrol that the watermark is pointing to, I'm getting this kind of error.
Assertion Failed: Duplicate use of ID on
Is it a conflict or but in watermark extender? I'm using the examples of atlas control toolkit as reference. I used the popup control extender and tried to add a watermark extender to one of the text boxes. Then the error appears.
Note: The reason I encountered a problem is because I'm trying to make a textbox with the AutoComplete extender. I thought that adding a watermark extender would make the textbox much more user friendly.
Thanks for any comments.Depending on how the extenders implement their functionality, they may conflict when pointed at the same control. If you post a simple sample, we should be able to identify the conflict if there is one.
Here is the sample code. It is basically a text box with a popup control extender. In the popup control extender you could type some text in the smaller text box and when you had click the Add button it would transfer the text to the larger text box on the top. I added the watermark textbox extender and it begins to show the error. The popup works when the watermark is not used and vice versa. I removed the styles.
Thanks for any help. :)
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering=true runat="server"></atlas:ScriptManager><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtEmailTo" Width=500px runat="server"></asp:TextBox> <div style="width:100%;height:3px;"></div> <asp:Panel BorderColor=black BorderStyle=solid BorderWidth=1px ID="pnlEmailTo" runat="server" Width="504px"> <atlas:UpdatePanel ID="UpdatePanel12" runat="server"> <ContentTemplate> <atlasToolkit:PopupControlExtender ID="PopupControlEmailTo" runat="server"> <atlasToolkit:PopupControlProperties OffsetX=0 OffsetY=2 TargetControlID="txtEmailTo" PopupControlID="pnlEmailto" Position="Bottom" /> </atlasToolkit:PopupControlExtender> <asp:TextBox ID="txtSampleTo" runat="server" Width="300px"></asp:TextBox> <center> <div style="width:100%;height:3px;"></div> <asp:Button ID="btnAddTo" UseSubmitBehavior=false runat="server" Width=120px Text="Add Text" OnClick="btnAddTo_Click" /> </center> </ContentTemplate> </atlas:UpdatePanel> </asp:Panel> <atlasToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"> <atlasToolkit:TextBoxWatermarkProperties TargetControlID="txtEmailTo" WatermarkText="I'm a watermark" /> </atlasToolkit:TextBoxWatermarkExtender> </div> </form></body></html>
CODE
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass Default2 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { }protected void btnAddTo_Click(object sender, EventArgs e) {try {if (this.txtEmailTo.Text.Trim().Length <= 0) {this.PopupControlEmailTo.Commit(this.txtEmailTo,this.txtEmailTo.Text.Trim().ToString() +this.txtSampleTo.Text.ToString()); }else {this.PopupControlEmailTo.Commit(this.txtEmailTo,this.txtEmailTo.Text.Trim().ToString() +";" +this.txtSampleTo.Text.ToString()); } }catch { } }}
I've just opened work item 224 to track this issue. It says:
"PopupControl and TextBoxWatermark both override the ID property so they can return specifically decorated IDs. This is okay, but they override the set method with a NOOP. This is bad because it means the base class's implementation that actually stores the ID for later use doesn't get called and therefore when pointing two extenders at the same control there will be no way to avoid both extenders assigning themselves the same ID ("_TargetControlID"). The set method should really do something like "base.ID = value;".
Once that's in place, it's possible to avoid the same-naming problem by assigning an ID to either or both of the relevant extender's property lists so that their generated IDs will be non-conflicting ("AssignedID_TargetControlID")."
Making that change and adding an ID to one of your two extenders pointing at the same control seems to fix the problem for me. The resulting behavior's still a little weird since they both key off of focus, etc., but at least it works and will allow non-conflicting extenders to point to the same control.
Thanks for bringing this up!
Ah I see...
Much thanks for the reply, I'd try it later today to see if it is really that weird. :)
Regards,
No comments:
Post a Comment