Beruflich Dokumente
Kultur Dokumente
LOGIN<br/>
<table border="0" cellpadding="0" cellspacing="0"
style="width: 337px; height: 96px" frame="border">
<tr> <td><asp:Label ID="Label1" runat="server"
Text="Login" Width="99px"></asp:Label></td>
<td>
<asp:TextBox ID="TextBox1" runat="server“ >
</asp:TextBox></td></tr><tr> Same
<td><asp:Label ID="Label2" runat="server" controls
Text="Password" Width="104px"></asp:Label></td>
<td><asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox></td></tr>
<tr><td></td>
<td><asp:Button ID="Button1" runat="server"
Text="submit" OnClick="Button1_Click"
/></td></tr></table>
Adding property in the web forms
page
<%@ Register Src="WebUserControl.ascx"
TagName="WebUserControl" TagPrefix="uc1"
%>
…
<body>
<form id="form1" runat="server">
<div>
<uc1:WebUserControl
id="WebUserControl1" runat="server"
DefaultLogin="admin">
</uc1:WebUserControl>
</div>
</form>
</body>
</html>
@Reference Directive
• This directive indicates that the page must be
compiled and linked with another user control or
page source file.
• One usage of this tag would be to display the
user control on the fly when an event occurs.
• This will require creation of the user control
reference and displaying it only when an event
happens.
• Example in the next slide demonstrates
associating a place holder with the user control
on clicking of a button.
Steps
1. Create a web form page.
2. Add a button and place holder tag inside the form tag
as shown below.
<form runat="server">
<asp:Button ID="Button1"
runat="server" OnClick="Button1_Click"
Text="show" /><br />
<asp:placeholder id="PlaceHolder"
runat="server"/>
</form>
3. Next add
<%@ Reference
Control="WebUserControl.ascx" %>
right below the page directive.
• Make the page directive to link up only to the scripts
associated with this page.
<%@ Page Language="C#" %>
• Double click on the button from the design view and
add the following code.
MyWebControl myControl =
(MyWebControl)Page.LoadControl("WebUserC
ontrol.ascx");
myControl.DefaultLogin = "user";
PlaceHolder.Controls.Add(myControl);