Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 14th, 2004, 11:40 AM
Authorized User
 
Join Date: Jul 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Tremmorkeep Send a message via MSN to Tremmorkeep Send a message via Yahoo to Tremmorkeep
Default Custom web controls

Ok, I'm pretty new to asp.net, and in classic asp, this would work just fine but I get a couple errors on this: Usually something in the flavor of "code blocks not allowed in this context" or something like that. Anyone?

--code begin
<%@ Control Language="c#" %>
<%@ Import namespace="DrcComponents" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web" %>
<%@ Import namespace="System.Data" %>
<%@ Register TagPrefix="drcControl" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>

<script language="c#" runat="server">
string strTabs="";

void Page_Load()
{
    ExcelSheets newSheet=new ExcelSheets();
    DataSet tabStuff=newSheet.GetExcelWorkSheet(@"F:\Share\MAN H",@"MNAA9B.XLS");


    foreach(DataTable myTable in tabStuff.Tables)
    {
        strTabs += "<drcControl:Tab Text=\"" + myTable.TableName + "\" />";
    }
    testThis.Text = strTabs.ToString();
}
</script>
<asp:TextBox id="testThis" runat="server" /><br />

<drcControl:TabStrip id="ts1" runat="server"
   TabDefaultStyle="color:#aaaaaa;background-color:#EEEEEE;
   border-color:#AAAAAA;border-width:1px;border-style:Solid;
   font-weight:bold;font-family:Verdana;font-size:11px;height:21;
   width:79;text-align:center;"
   TabHoverStyle="color:blue"
   TabSelectedStyle="color:#000000;background-color:#FFFFFF;
   border-bottom:none"
   SepDefaultStyle="background-color:#FFFFFF;border-color:#AAAAAA;
   border-width:1px;border-style:solid;border-top:none;border-left:none;
   border-right:none">
   <%=strTabs%>

    <drcControl:Tab Text="Contact Us" />
    <drcControl:Tab Text="Home" />
</drcControl:TabStrip>

--code end
 
Old June 16th, 2004, 12:56 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What is strTabs?
 
Old June 16th, 2004, 02:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I see a couple of server tags that don't have runat="server" attribute declared... could this be a problem?

Also, instead of writing the content to the screen, in ASP.NET you need to create the object and add it to a collection, similar to:

Dim objControl as new Microsoft.We.Ui.WebControls.Tab
objControl.Text = myTable.TableName
ts1.Controls.Add(objControl)

also, you may want to put this code around:

if ( !Page.IsPostback ) {

}

So that the addition will only happen once.

Hope this helps,

Brian
 
Old June 16th, 2004, 02:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Oh I should state that I've never used that control before and my syntax may be incorrect.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Service, Custom Control, Custom Return Type robzyc ASP.NET 2.0 Basics 6 June 10th, 2008 08:03 AM
Creating web custom controls problem Lerik ASP.NET 1.0 and 1.1 Professional 0 January 6th, 2006 06:39 AM
Creating Web Custom Controls Lerik C# 2005 0 January 6th, 2006 04:55 AM
Web Custom Controls Me VS.NET 2002/2003 2 July 15th, 2004 01:48 AM
"Programming web custom controls" bluetrane VS.NET 2002/2003 1 August 12th, 2003 11:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.