How use WebUserControl

G

Guest

Hi

I create WebUserControl and very confused when use control

For Example:

*****************************
*wuc.ascx
*****************************
<script id=clientEventHandlersJS language=javascript>
<!--

function selMap_onclick() {
//???? here is my problem
}

//-->
</script>
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="wuc.ascx.vb"
Inherits="localhost.wuc"
targetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

<div id="divSelMap" runat="server">
<SELECT size="5" style="WIDTH: 100%; HEIGHT: 100%" id="selMap"
name="selMap" runat="server" language=javascript onclick="return
selMap_onclick()">
</SELECT>
</div>

*****************************
* test.aspx
*****************************
<%@ Register TagPrefix="uc1" TagName="wuc" Src="wuc.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb"
Inherits="localhost.test" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
......................................................
</HEAD>
<body MS_POSITIONING="FlowLayout" topmargin="0" bottommargin="0"
leftmargin="0" rightmargin="0">
<form id="Form1" method="post" runat="server"
action="test.aspx?wuc=MapPrewiev">
<uc1:wuc id="Wuc" runat="server"></uc1:wuc>
</form>
</body>
</HTML>

*****************************
* In Internet Explorer -> ViewSource I see that:
*****************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
......................................................
......................................................
</HEAD>
<body MS_POSITIONING="FlowLayout" topmargin="0" bottommargin="0"
leftmargin="0" rightmargin="0">
<form name="Form1" method="post" action="test.aspx" id="Form1">
......................................................
......................................................
<script id=clientEventHandlersJS language=javascript>
<!--
function selMap_onclick() {
//???? here is my problem
}
//-->
</script>

<div id="Wuc_divSelMap"
style="DISPLAY:yes;Z-INDEX:99;LEFT:150px;WIDTH:200px;POSITION:absolute;TOP:20px;HEIGHT:150px;">
<select name="Wuc:selMap" id="Wuc_selMap" size="5" style="WIDTH: 100%;
HEIGHT: 100%" language="javascript" onclick="return selMap_onclick()">
<option value="Bulgaria">Bulgaria</option>
<option value="Sofia&Neighbours">Sofia&Neighbours</option>
<option value="Europa">Europa</option>
<option value="Sofia">Sofia</option>
<option value="Blagoevgrad">Blagoevgrad</option>
<option value="Burgas">Burgas</option>
<option value="Haskovo">Haskovo</option>
</select>
</div>
</form>
</body>
</HTML>

The "<SELECT>" in end source from IE have new NAME="Wuc:selMap" and
ID="Wuc_selMap"
I don`t know what i do when place WebUserControl in other page (test2.aspx)
with other "TagName=", or when I use this WebUserControl several thimes in
one page???
 
G

Guest

Hi I know a little about this as I have created one and used it throughout my
web application. To add it to a form simply drag it from the solution
explorer to the form and position it in the desired location. To get to its'
properties, for example if you want to hide or display the control
conditionally in the vb file add something like
For Each ctrl As Control In Me.Controls
ctrl.FindControl("usercontrolname").Visible = False
Next
 

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

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top