Hello All,
I'm just now getting to WebUserControl in WebControlLibraries and am
having some trouble. I'm missing something basic, but I can't figure
it out.
I have a web control library project (WebControlLibrary1) which
contains a single control (WCustCtrl) which is just the template from
the IDE designer.
Obviously this compiles into WebControlLibrary.dll without problem. I
can use this control in my ASPX pages with out any trouble, but I can
not seem to use this in my generic HTML page.
I'm not sure if the problem is how I'm calling the object or if I'm
missing something in my class. Is it even possible to use this class
from a generic HTML page?
Any help would be appreciated.
-tomas
Here's what I have for the HTML page:
<HTML>
<HEAD>
</HEAD>
<BODY>
<OBJECT
id="MyWinControl2"
classid="http://localhost/WebControlLibrary1.dll#WebControlLibrary1.WCustCtr l"
height="200" width="200" style="display:inline;"
VIEWASTEXT >
</OBJECT>
</BODY>
<script>
var MyUserControl;
MyUserControl = document.getElementById('MyWinControl2');
alert("objText.Run=" + MyUserControl.Text);
</script>
</HTML>
//---
// This is the entire class file
//---
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace WebControlLibrary1
{
/// <summary>
/// Summary description for WCustCtrl.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WCustCtrl runat=server></{0}:WCustCtrl>")]
public class WCustCtrl : System.Web.UI.WebControls.WebControl
{
private string text = "InitText";
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
protected override void Render(HtmlTextWriter output)
{
output.Write(Text);
}
//---
// Class/Namespace closing brackets
//---
}
}