Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

Writing a html string from a sub in a user control file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christian Perthen - 14 Feb 2006 16:42 GMT
Hi,

I have a sub in the codebehind page of a user control file that writes html.
How do I get the sub triggered and output the html in the content page?
See my approach below.

Partial Class contentAffiliate
   Inherits System.Web.UI.UserControl

Sub Page_Load()
   writeContentAffiliateSub(1, 1)
End Sub

Sub writeContentAffiliateSub(ByVal intDisplayMode As Integer, ByVal
intPageID As Integer)
   Response.Write("<table cellpadding=""0"" cellspacing=""0""><tr>")
   Response.Write("<td nowrap " & writeActiveTab(intPageID, 1) & "><a
href=""affiliate_list.aspx"">Active Affiliates</a></td>")
   Response.Write("<td nowrap " & writeActiveTab(intPageID, 2) & "><a
href=""affiliate_list.aspx?active=1"">Temporary Affiliates</a></td>")
   Response.Write("<td nowrap " & writeActiveTab(intPageID, 3) & "><a
href=""affiliate_list.aspx?active=0"">Inactive Affiliates</a></td>")
   Response.Write("<td nowrap " & writeActiveTab(intPageID, 4) & "><a
href=""affiliate_new.asp"">New Affiliate</a></td>")
   Response.Write("<td nowrap " & writeActiveTab(intPageID, 5) & "><a
href=""affiliate_usage.asp"">Affiliate Usage</a></td>")
   Response.Write("</tr></table>")
End Sub

Function writeActiveTab(ByVal intPageID As Integer, ByVal intTabID As
Integer) As String
   If intPageID = intTabID Then
       writeActiveTab = "class=""active"""
   Else
       writeActiveTab = "class=""inactive"""
   End If
End Function

End Class

in the content page I have:

<%@ Register TagPrefix="tab" TagName="contentAffiliate"
Src="~\controls\contentAffiliate.ascx" %>

<tab:contentAffiliate id="contentAffiliate"
runat="server"/></tab:contentAffiliate>

But nothing is generated

Any insight on this?

Thanks in advance
Christian
Kris - 14 Feb 2006 19:09 GMT
Hi Christian,

Add Table tag in .ascx page as a server HTML tag, and add the rows and
columns to the table from code behind file.

<table id="tblDisplay" runat="server"></table>

Dim dRow as New HtmlTableRow
Dim dColumn as New HtmlTableColumn

dColumn.Text = "test"
dRow.Columns.add(dColumn)
tblDisplay.Rows.Add(dRow)

Hope this would help you.

Cheers,
Kris

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.