Admin
|
 |
 |
| Присоединился: 18 Mar 2003 |
| Число сообщений: 36 |
| |
|
New Interface IBS - signin.ascx
Отправлено: 18 Mar 2003 07:02 PM |
KMotion:
This is interesting, as I read the DeskTopDefault.aspx.cs for my CSharp Portal I noticed
that the correct format for adding this control to be:
ContentPane.Controls.Add(Page.LoadControl("~/DesktopModules/SignIn.ascx"));
In your code I noticed a lack of the Page.LoadControl directive...
ContentPane.Controls.Add("~/DesktopModules/Sign.ascx");
As an alternative to this Visual Studio gives an example which you may find useful for clarity
when you find yourself in situations where you need to add a custom usercontrol:
[Visual Basic]
Public Function LoadControl( ByVal virtualPath As String) As Control
[C#]
public Control LoadControl(string virtualPath);
[Visual Basic]
<%@ Page Language='VB'%>
<%@ Reference Control='Logonform.vb.ascx' %>
<html>
<body>
<script language="VB" runat="server">
Sub Page_Init(Sender As Object, e As EventArgs )
Response.Write("<h4> A Reusable Simple User Control</h4><br>")
'Obtain a UserControl object 'LogOnControl' from the user control file 'Logonform.ascx'.
Dim myControl As LogOnControl = CType (LoadControl("Logonform.vb.ascx"),LogOnControl)
Controls.Add(myControl)
End Sub
</script>
</body>
</html>
[C#]
<%@ Page Language='c#'%>
<%@ Reference Control='Logonform.cs.ascx' %>
<html>
<head>
<script language="C#" runat="server">
void Page_Init(object sender, System.EventArgs e)
{
Response.Write("<h4> A Reusable Simple User Control</h4><br>");
// Obtain a UserControl object 'LogOnControl' from the user control file 'Logonform.ascx'.
LogOnControl myControl = (LogOnControl)LoadControl("Logonform.cs.ascx");
Controls.Add(myControl);
}
</script>
</head>
</html>
[Visual Basic]
'File name: logoncontrol.vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class LogOnControl Inherits UserControl
Public user As TextBox
Public password As TextBox
End Class 'LogOnControl
'File name: Logonform.vb.ascx
<%@ control inherits = "LogOnControl" src = "LogOnControl.vb" %>
<table style=font: 10pt verdana;border-width:1;border-style:solid;border-color:black;" cellspacing=15>
<tr>
<td>Login: </td>
<td><ASP:TextBox id="user" runat="server"/></td>
</tr>
<tr>
<td>Password: </td>
<td><ASP:TextBox id="password" TextMode="Password" runat="server"/></td>
</tr>
<tr></tr>
</table>
[C#]
//File name: logoncontrol.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
public class LogOnControl:UserControl
{
public TextBox user;
public TextBox password;
}
//File name: Logonform.cs.ascx
<%@ control inherits = "LogOnControl" src = "LogOnControl.cs" %>
<table style=font: 10pt verdana;border-width:1;border-style:solid;border-color:black;" cellspacing=15>
<tr>
<td>Login: </td>
<td><ASP:TextBox id="user" runat="server"/></td>
</tr>
<tr>
<td>Password: </td>
<td><ASP:TextBox id="password" TextMode="Password" runat="server"/></td>
</tr>
<tr></tr>
</table>
Hope this helps!
Nemi |
//Igor
|
|
|
|