Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Bug in ie webcontrol, tab.cs

Reply
Thread Tools

Bug in ie webcontrol, tab.cs

 
 
mawi
Guest
Posts: n/a
 
      07-07-2004
Hello,

I dont know if this a known bug but I found this one error
in the "tab.cs" code for the tab class in the IE
webcontrols package.

The method WriteItemAttributes has this code (line 150):

if (TargetID != String.Empty)
{
writer.WriteAttribute("targetID",
Target.ClientID);
}

This causes a problem if at this point the pageviews have
not been instantiated, or the like - ie the object is not
yet ready. The first time the target is accessed, it will
use the targetid property and get a reference to a control,
at which time it is more probable it is ready.

If one simply uses the property that is used in the check
(TargetID) in the assignment the control works better, like so:

if (TargetID != String.Empty)
{
writer.WriteAttribute("targetID", TargetID);
}


This yields no problems whatsoever afaics. Some notes:

(1) This looks like it is unintentional, but it may be
intentional and represent an implicit assumption that is
not apparent from the code. But the check should be the
same as used in the assignment, in my mind.

(2) If intentional it is strange because the code will
cause a null reference exception to be thrown when the
pageview control has not yet been instantiated, the reason
for which is very hard to see without the source (which is
obviously the reason for me getting it and finding this).
If intentional there should be some more descriptive message.


With the bug fixed, dynamic tabs / pageviews works more as
one would assume, without error.


I could post a build with the bugfix somewhere, my own
server is currently a little bit out of order. In order to
build the webcontrols I recommend Peter Brombergs project
(which I used) which makes fixing and building a snap. Find
it at http://www.eggheadcafe.com/articles/20030426.asp.

As soon as I have time I will post a project illustrating
the problem, but here is a code excerpt:

(the form has an empty tabstrip and multipage, one (server,
asp) button "add tab" and one button "do roundtrip")

The first mehtod is the addtab event handler:

private void Button3_Click(object sender, System.EventArgs e)
{
String count = (TabStrip1.Items.Count + 1).ToString();
PageView pv = CreatePageView( count );
Tab t = CreateTab( count, pv.ID );
MultiPage1.Controls.Add( pv );
TabStrip1.Items.Add( t );
}
private void Page_Load(object sender, System.EventArgs e)
{
int pageCount = TabStrip1.Items.Count;
if ( pageCount > 0 )
for ( int i = 1; i <= pageCount; i++ )
MultiPage1.Controls.Add( CreatePageView( i.ToString() ) );
}
private void DoRoundTrip(object sender, System.EventArgs
e) { }
private Tab CreateTab ( String count, String pageID )
{
Tab tempTab = new Tab();
tempTab.ID = "dyn_tab_" + count;
tempTab.Text = "Tab " + count;
tempTab.TargetID = pageID;
return tempTab;
}
private PageView CreatePageView ( String count )
{
PageView tempPage = new PageView();
tempPage.EnableViewState = false;
tempPage.ID = "page_" + count;
Literal lit = new Literal();
lit.Text = "<H1>Page for tab " + count + "</H1>";
tempPage.Controls.Add( lit );
return tempPage;
}


Without the bugfix, I get a null reference exception. With
it, this works as expected.

Maybe I have an old version, but I dont think so.

Comments?


Second; please help me out with how one best persists the
child controls of a pageview, is there a simple way? Does
not have to be recursive. Do I have to code the
load/saveviewstate methods myself? Tips greatly
appreciated. See post I made earlier today for more info on
this issue. Thanks alot!


/mawi
m(yup, single m)(at)mawi(dot)org
 
Reply With Quote
 
 
 
 
mawi
Guest
Posts: n/a
 
      07-08-2004
Sample testpage, save as aspx file in a webroot, put
"Microsoft.Web.UI.WebControls.dll" in "bin" directory of
that root. Vanilla package will throw nullexception, with
bugfix this works.

//mawi

<%@ Page language="c#" AutoEventWireup="true" %>
<%@ Register TagPrefix="iewc"
Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %>
<script runat="server">
void Page_Load()
{
for ( int i = 1; i <= TabStrip1.Items.Count; i++ )
NewPV( i.ToString() );
}
private String NewPV( String count )
{
PageView pv = new PageView();
pv.Controls.Add( new Literal() );
( pv.Controls[ 0 ] as Literal ).Text = "<H1>Page for tab
" + count + "</H1>";
MultiPage1.Controls.Add( pv );
return (pv.ID = "page_" + count);
}
private void addTab(object sender, System.EventArgs e)
{
String count = (TabStrip1.Items.Count + 1).ToString();
Tab t = new Tab();
t.Text = t.ID = "Tab_" + count;
t.TargetID = NewPV( count );
TabStrip1.Items.Add( t );
}
</script>
<html>
<body>
<form runat="server">
<asp:button id="addBtn" runat="server" Text="+Tab"
OnClick="addTab" />
<iewc:tabstrip id="TabStrip1" runat="server"
targetid="MultiPage1" />
<iewc:multipage id="MultiPage1" runat="server" />
</form>
</body>
</html>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
ASP.NET Login control bug or SQL 2005 bug? RedEye ASP .Net 2 12-13-2005 10:57 AM
Re: BUG? OR NOT A BUG? John ASP .Net 2 09-21-2005 10:31 AM
Bug Parade Bug 4953793 Michel Joly de Lotbiniere Java 4 12-02-2003 05:05 AM
how to report bug to g++ ? got a bug and fixed up source code DarkSpy C++ 4 06-27-2003 09:05 AM



Advertisments