rhr
March 24th, 2006, 12:06 PM
Working with MasterPages can get really frustrating sometimes. I guess I dont understand them right; perhaps someone up here can help me solve my problem.
I created a class that generates html [as in Table and Links] using database. Anyway long story short I get raw html in a sting. When I try to write that string (and I have used several methods which I will mention below) every thing works great on root level but as soon I go one or two folder level deep, my links start acting funky, my images doesn't appear all sorts of bad stuff happens.
lets say my folder hierarchy is something like: Root > Department > Area > ASPXPage.aspx
My MasterPage is at RootLevel and so is my Content Page Home.aspx, when I click on the link, in the menu, to get to ASPXPage.aspx every thing works fine and I get to that page with no problem, but when I click on the same link, in the menu, again my URL looks like this:
Root > Department > Area > Department > Area >ASPXPage.aspx
/* the href value is "Department/Area/ASPXPage.aspx" */
Well I thought maybe I needed to add runat = server to my so I did, do you think it worked after that? Heck No!!!
Also my Images [show hide menu] that are in the Images folder [under root: Root > Images] wont display, instead I get an ugly [x]. Below are the things I have tried so far:
//Lets say myRawHtmlString has the html
Ok, I have tried:
lblWriteHtml.Text = myRawHtmlString; [user label control does not work]
litWriteHtml.Text = myRawHtmlString; [Literal control, does not work]
CustomHtmlWriter McC = new CustomHtmlWriter (); [Created a custom control :-s]
this.Controls.Add(McC);
McC.HtmlString = myRawHtmlString; [DOES NOT WORK]
/* THIS IS WHAT MY CUSTOM CONTROL CLASS LOOK LIKE */
using System;
using System.Data;
using System.Configuration;
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 class CustomHtmlWriter : Control
{
private string _HTMLString;
public virtual string HTMLStrin
{
get { return _HTMLString; }
set { _HTMLString = value; }
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write(this._HTMLString);
}
}
Can anyone please help me solve this problem???
I created a class that generates html [as in Table and Links] using database. Anyway long story short I get raw html in a sting. When I try to write that string (and I have used several methods which I will mention below) every thing works great on root level but as soon I go one or two folder level deep, my links start acting funky, my images doesn't appear all sorts of bad stuff happens.
lets say my folder hierarchy is something like: Root > Department > Area > ASPXPage.aspx
My MasterPage is at RootLevel and so is my Content Page Home.aspx, when I click on the link, in the menu, to get to ASPXPage.aspx every thing works fine and I get to that page with no problem, but when I click on the same link, in the menu, again my URL looks like this:
Root > Department > Area > Department > Area >ASPXPage.aspx
/* the href value is "Department/Area/ASPXPage.aspx" */
Well I thought maybe I needed to add runat = server to my so I did, do you think it worked after that? Heck No!!!
Also my Images [show hide menu] that are in the Images folder [under root: Root > Images] wont display, instead I get an ugly [x]. Below are the things I have tried so far:
//Lets say myRawHtmlString has the html
Ok, I have tried:
lblWriteHtml.Text = myRawHtmlString; [user label control does not work]
litWriteHtml.Text = myRawHtmlString; [Literal control, does not work]
CustomHtmlWriter McC = new CustomHtmlWriter (); [Created a custom control :-s]
this.Controls.Add(McC);
McC.HtmlString = myRawHtmlString; [DOES NOT WORK]
/* THIS IS WHAT MY CUSTOM CONTROL CLASS LOOK LIKE */
using System;
using System.Data;
using System.Configuration;
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 class CustomHtmlWriter : Control
{
private string _HTMLString;
public virtual string HTMLStrin
{
get { return _HTMLString; }
set { _HTMLString = value; }
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write(this._HTMLString);
}
}
Can anyone please help me solve this problem???