Using wincontrols in aspx page

M

Mark Goldin

I am trying to put together a small project where I will learn how to embed
win controls in apsx pages. So far I got some code.
When I run an aspx page nothing is shown on the page. Here is a class code:
using System;

using System.Collections;

using System.ComponentModel;

using System.Drawing;

using System.Data;

using System.Windows.Forms;

using System.Runtime.InteropServices;



namespace MyButtonControl

{

[GuidAttribute("1F98211C-7A71-4588-8D4A-AD85CA80BAE7"),

InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]

public interface ControlEvents

{

// Add DisIdAttribute to any members in the source interface to specify

//the COM DISPID.

[DispIdAttribute(1)]

void MyButtonClicked(object sender, System.EventArgs e);

}





// Add a ComSourceInterfaces attribute to the control to identify the list

// of interfaces that are exposed as COM event sources.

[ComSourceInterfaces("MyButtonControl.ControlEvents")]

public class MyButton : System.Windows.Forms.UserControl

{

private System.Windows.Forms.Button MyButton1;

// delegate for the event. We can use System.EventHandler here because

// we use the same args.

public event System.EventHandler MyButtonClicked;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

public MyButton()

{

// 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 );

}



protected virtual void OnClicked(EventArgs e)

{

// pass the event to the COM interface

if ( MyButtonClicked != null)

{

MyButtonClicked(this, e);

}

}

private void InitializeComponent()

{

//

// MyButton

//

this.Name = "MyButton";

}

// the intern control click event

private void MyButton1_Click(object sender, System.EventArgs e)

{

// handle it

OnClicked(EventArgs.Empty);

}

}

}



and here is aspx code:

<%@ Page language="c#" Codebehind="test.aspx.cs" AutoEventWireup="false"
Inherits="processmonitor.test" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>test</title>
<META content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<META content="C#" name="CODE_LANGUAGE">
<META content="JavaScript" name="vs_defaultClientScript">
<META content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<BODY MS_POSITIONING="GridLayout">
<FORM id="Form1" method="post" runat="server">
<OBJECT id="Button2"
data="data:application/x-oleobject;base64,IGkzJfkDzxGP0ACqAGhvEzwhRE9DVFlQRS
BIVE1MIFBVQkxJQyAiLS8vVzNDLy9EVEQgSFRNTCA0LjAgVHJhbnNpdGlvbmFsLy9FTiI+DQo8SF
RNTD48SEVBRD4NCjxNRVRBIGh0dHAtZXF1aXY9Q29udGVudC1UeXBlIGNvbnRlbnQ9InRleHQvaH
RtbDsgY2hhcnNldD13aW5kb3dzLTEyNTIiPg0KPE1FVEEgY29udGVudD0iTVNIVE1MIDYuMDAuMz
c5MC4xMTgiIG5hbWU9R0VORVJBVE9SPjwvSEVBRD4NCjxCT0RZPg0KPFA+Jm5ic3A7PC9QPjwvQk
9EWT48L0hUTUw+DQo="

classid="http://localhost/processmonitor/MyButtonControl.dll#MyButtonControl
..MyButton"
VIEWASTEXT>
</OBJECT>
<SCRIPT language="javascript" event="MyButtonClicked()" for="Button2">
<!--
// after catching the user event do some stuff...
window.location.href = "http://www.dell.com";
//-->
</SCRIPT>
</FORM>
</BODY>
</HTML>


Please help.

Thanks
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top