Reputation: 1820
everybody!
I know, that probably the question was asked many times, but anyway..
The problem is:
I have a solution with 2 projects (C# Class Library and Web-project). In class library project I've overriden a text box control, so it has built-in validations. On local server everything works nice, but when I upload published project, the problems begin.
Here's the code:
[Browsable(true)]
[Category("Appearance")]
[DefaultValue("~/images/alert.png")]
public string AlertImageUrl
{
get
{
string path = HttpContext.Current.Server.MapPath("~/images/alert.png");
return GetPropertyValue<string>("AlertImageUrl", path);
}
set
{
SetPropertyValue("AlertImageUrl", value);
}
}
protected override void Render(HtmlTextWriter writer)
{
this.Attributes["onfocus"] = "var objs = this.parentNode.childNodes; for (var i = 0; i < objs.length; i++) {if (objs[i].id == 'imgAlert') { objs[i].style.display = 'none'; } }";
writer.WriteFullBeginTag("span");
base.Render(writer);
if (!_validator.IsValid)
{
writer.WriteBeginTag("img");
writer.WriteAttribute("id", "imgAlert");
writer.WriteAttribute("runat", "server");
writer.WriteAttribute("style", "left: -20px; top: 3px;");
writer.WriteAttribute("src", AlertImageUrl);
writer.WriteEndTag("img");
}
writer.WriteEndTag("span");
}
Image is located in App_Themes/Theme_name/images/alert.png How to get AlertImageUrl correctly? Strange, if I manually set it returns correct path, but WriteAttribute - no..
Any help is appreciated, Regards, Maris
Upvotes: 1
Views: 556