Using Windows Control in ASP.NET

  • Thread starter Thread starter Chung
  • Start date Start date
C

Chung

Hi

I am trying to create a Web applicatiion by using windows
user control. I am having problem when I trying to load
the web page, I got blank screen with a broken image. It
is like the web page trying to load an image but the file
is not in the Folder.

I have set the Execute Permissions to Scipts only in IIS.
I have also checked the index.html and Win_Ctrl_Lib.dll
are in the same folder. Then Namespace and the control
method is correct too.

Is anyone can help me?

Regards,
Chung


Here is my code


HTML Code index.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft
Visual Studio 7.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<OBJECT id="UserControl1"
classid="Win_Ctrl_Lib.dll#Win_Ctrl_Lib.UserControl1"
width="800" height="600" style="font-size:12;" VIEWASTEXT>
</OBJECT>
</BODY>
</HTML>


c# Window Control Win_Ctrl_Lib.dll:

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

using System.Diagnostics;


namespace Win_Ctrl_Lib
{
/// <summary>
/// Summary description for UserControl1.
/// </summary>
public class UserControl1 :
System.Windows.Forms.UserControl
{
private System.Windows.Forms.TextBox
S_tb;
private System.Windows.Forms.Button
Encrypt_btn;

/// Required designer variable.
private System.ComponentModel.Container
components = null;

public UserControl1()
{
// This call is required by the
Windows.Forms Form Designer.
InitializeComponent();

// TODO: Add any initialization
after the InitForm call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool
disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose
();
}
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.S_tb = new
System.Windows.Forms.TextBox();
this.Encrypt_btn = new
System.Windows.Forms.Button();
this.SuspendLayout();
//
// S_tb
//
this.S_tb.Location = new
System.Drawing.Point(10, 10);
this.S_tb.Multiline = true;
this.S_tb.Name = "S_tb";
this.S_tb.Size = new
System.Drawing.Size(256, 50);
this.S_tb.TabIndex = 0;
this.S_tb.Text = "S:";
//
// Encrypt_btn
//
this.Encrypt_btn.Location = new
System.Drawing.Point(304, 16);
this.Encrypt_btn.Name
= "Encrypt_btn";
this.Encrypt_btn.Size = new
System.Drawing.Size(76, 21);
this.Encrypt_btn.TabIndex = 2;
this.Encrypt_btn.Text = "Go";
this.Encrypt_btn.Click += new
System.EventHandler(this.Encrypt_btn_Click);
//
// UserControl1
//
this.BackColor =
System.Drawing.Color.White;
this.Controls.AddRange(new
System.Windows.Forms.Control[] {


this.S_tb,


this.Encrypt_btn});
this.Name = "UserControl1";
this.Size = new System.Drawing.Size
(600, 300);
this.ResumeLayout(false);

}
#endregion

private void Encrypt_btn_Click(object
sender, System.EventArgs e)
{
S_tb.Text = "Button Clicked";
}
}
}
 
Here are some links that should be able to give you some guidance:
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsIeSourcing.aspx
http://msdn.microsoft.com/msdnmag/issues/02/06/Rich/default.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com



Chung said:
Hi

I am trying to create a Web applicatiion by using windows
user control. I am having problem when I trying to load
the web page, I got blank screen with a broken image. It
is like the web page trying to load an image but the file
is not in the Folder.

I have set the Execute Permissions to Scipts only in IIS.
I have also checked the index.html and Win_Ctrl_Lib.dll
are in the same folder. Then Namespace and the control
method is correct too.

Is anyone can help me?

Regards,
Chung


Here is my code


HTML Code index.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft
Visual Studio 7.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<OBJECT id="UserControl1"
classid="Win_Ctrl_Lib.dll#Win_Ctrl_Lib.UserControl1"
width="800" height="600" style="font-size:12;" VIEWASTEXT>
</OBJECT>
</BODY>
</HTML>


c# Window Control Win_Ctrl_Lib.dll:

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

using System.Diagnostics;


namespace Win_Ctrl_Lib
{
/// <summary>
/// Summary description for UserControl1.
/// </summary>
public class UserControl1 :
System.Windows.Forms.UserControl
{
private System.Windows.Forms.TextBox
S_tb;
private System.Windows.Forms.Button
Encrypt_btn;

/// Required designer variable.
private System.ComponentModel.Container
components = null;

public UserControl1()
{
// This call is required by the
Windows.Forms Form Designer.
InitializeComponent();

// TODO: Add any initialization
after the InitForm call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool
disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose
();
}
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.S_tb = new
System.Windows.Forms.TextBox();
this.Encrypt_btn = new
System.Windows.Forms.Button();
this.SuspendLayout();
//
// S_tb
//
this.S_tb.Location = new
System.Drawing.Point(10, 10);
this.S_tb.Multiline = true;
this.S_tb.Name = "S_tb";
this.S_tb.Size = new
System.Drawing.Size(256, 50);
this.S_tb.TabIndex = 0;
this.S_tb.Text = "S:";
//
// Encrypt_btn
//
this.Encrypt_btn.Location = new
System.Drawing.Point(304, 16);
this.Encrypt_btn.Name
= "Encrypt_btn";
this.Encrypt_btn.Size = new
System.Drawing.Size(76, 21);
this.Encrypt_btn.TabIndex = 2;
this.Encrypt_btn.Text = "Go";
this.Encrypt_btn.Click += new
System.EventHandler(this.Encrypt_btn_Click);
//
// UserControl1
//
this.BackColor =
System.Drawing.Color.White;
this.Controls.AddRange(new
System.Windows.Forms.Control[] {


this.S_tb,


this.Encrypt_btn});
this.Name = "UserControl1";
this.Size = new System.Drawing.Size
(600, 300);
this.ResumeLayout(false);

}
#endregion

private void Encrypt_btn_Click(object
sender, System.EventArgs e)
{
S_tb.Text = "Button Clicked";
}
}
}
 
Back
Top