J
Jonathan Wood
Below is a user control (ascx file) I created.
Everything works fine except, when I first place an instance of the control
on a form and look at the associated properties, my initial property values
appear blank. They only show a value if I enter a new value.
What is the trick to have my default property values appear in the
properties window?
Thanks.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
<%@ Control Language="C#" ClassName="HelpButton" %>
<script runat="server">
protected string _helpFile = "Help.aspx";
protected string _imageUrl = "Help.png";
public string HelpFile
{
get { return _helpFile; }
set { _helpFile = value; }
}
public string ImageURL
{
get { return _imageUrl; }
set { _imageUrl = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
RegisterClientScripts();
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
// Render control
writer.Write(String.Format("<input type=\"image\" src=\"{0}\" alt=\"Help\"
onclick=\"javascript:return ShowHelp('{1}');\" style=\"border-width:0px;\",
/>",
ResolveUrl("~/Images/Help.jpg"), ResolveUrl("~/Help/" + HelpFile)));
}
protected void RegisterClientScripts()
{
// Create client-side scripts to generate kilograms from pounds and vice
versa
if (!Page.ClientScript.IsClientScriptBlockRegistered("ShowHelp"))
{
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "ShowHelp",
"function ShowHelp(url){" +
"window.open(url, \"_blank\",
\"height=300,width=450,toolbar=no,status=no,menubar=no,location=no,scrollbars=yes\");"
+
"return false;}", true);
}
}
</script>
Everything works fine except, when I first place an instance of the control
on a form and look at the associated properties, my initial property values
appear blank. They only show a value if I enter a new value.
What is the trick to have my default property values appear in the
properties window?
Thanks.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
<%@ Control Language="C#" ClassName="HelpButton" %>
<script runat="server">
protected string _helpFile = "Help.aspx";
protected string _imageUrl = "Help.png";
public string HelpFile
{
get { return _helpFile; }
set { _helpFile = value; }
}
public string ImageURL
{
get { return _imageUrl; }
set { _imageUrl = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
RegisterClientScripts();
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
// Render control
writer.Write(String.Format("<input type=\"image\" src=\"{0}\" alt=\"Help\"
onclick=\"javascript:return ShowHelp('{1}');\" style=\"border-width:0px;\",
/>",
ResolveUrl("~/Images/Help.jpg"), ResolveUrl("~/Help/" + HelpFile)));
}
protected void RegisterClientScripts()
{
// Create client-side scripts to generate kilograms from pounds and vice
versa
if (!Page.ClientScript.IsClientScriptBlockRegistered("ShowHelp"))
{
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "ShowHelp",
"function ShowHelp(url){" +
"window.open(url, \"_blank\",
\"height=300,width=450,toolbar=no,status=no,menubar=no,location=no,scrollbars=yes\");"
+
"return false;}", true);
}
}
</script>