TabStrip web control

G

Gabriel Enea

Hello,

I'm trying to develop my TabStrip web control but seems there is some
troubles in the desing mode.
Initially, I have defined a collection of TabButton in the TabStrip web
control. The TabButton inherits the functionality of the
System.Web.UI.WebControls.Button. In the Render method, for each tab I've
added the click javascript event as follows:

protected override void Render(HtmlTextWriter output)
{
....
but.Attributes.Add("onclick", "javascript: " +
Page.GetPostBackEventReference(this, "but" + i.ToString()));
....

But, after that I've a problem in the design mode when I try to add more
items (TabButton instance in the Items (TabButtonCollection) collection
because the VS adds automatically the 'click' attribute in the design mode:

<cc1:TabStrip id="TabStrip3" style="Z-INDEX: 103; LEFT: 152px; POSITION:
absolute; TOP: 352px" runat="server">
<cc1:TabButton Text="tabButton1" onclick="javascript:
__doPostBack('TabStrip3','but0')"></cc1:TabButton>
<cc1:TabButton Text="tabButton2" onclick="javascript:
__doPostBack('TabStrip3','but1')"></cc1:TabButton>
<cc1:TabButton Text="tabButton3" onclick="javascript:
__doPostBack('TabStrip3','but2')"></cc1:TabButton>
</cc1:TabStrip>

which should like:

<cc1:TabStrip id="TabStrip3" style="Z-INDEX: 103; LEFT: 152px; POSITION:
absolute; TOP: 352px" runat="server">
<cc1:TabButton Text="tabButton1"></cc1:TabButton>
<cc1:TabButton Text="tabButton2"></cc1:TabButton>
<cc1:TabButton Text="tabButton3"></cc1:TabButton>
</cc1:TabStrip>


Please, tell me if there is a way to know in the control if I am in the
design mode or at runtime. Note that the control renders correctly at the
runtime.


Best regards,

Gabriel.
 
S

Scott Wisniewski

You are seing this becuase you are generating Java Scipt in the render
method, which is called by the designer when displaying your page in design
view.

If you override the OnPreRedner method, and use
Page.RegisterClientScriptBlock or Page.RegisterStartupScript to register
your script on the page your script code will be rendered by the page's
render method, and not by the control. When viewed in the deisgner the page
will not render any registered script blocks.


-Scott Wisniewski
 

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,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top