WebUserLibrary/Control Basics

T

Tomas Vera

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.WCustCtrl"
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
//---
}
}
 
M

Mark White

Tomas

A generic HTML page will not be able to use this, or any other .Net
component.

HTML pages, unless directed otherwise (settings in IIS) are not run through
the aspnet dll. They are only delivered to the client via IIS, not ASP.NET.

It sounds like you are already using it correctly through the .aspx pages.

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top