Groups | Blog | Home
all groups > dotnet windows forms > july 2005 >

dotnet windows forms : Smart Client (WinForm) does not render in Browser (IE)



Chris Fink
7/7/2005 9:09:10 AM
The following code is intended to display a winform (DateTimePicker Control)
in a browser. But, when the aspx page that contains the reference to the
winform in the object tag is run, all that is displayed is a blank
placeholder and not the control. Any ideas or help is appreciated!

DateTimePicker.cs WinForm control code - output type class library
===========================================
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Windows.Control.Library
{
/// <summary>
/// Summary description for DateTimePicker.
/// </summary>
public class DateTimePicker : System.Windows.Forms.Form
{
private System.Windows.Forms.DateTimePicker dateTimePicker1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public DateTimePicker()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent 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 Windows Form 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.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(40, 40);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.TabIndex = 0;
//
// DateTimePicker
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.dateTimePicker1);
this.Name = "DateTimePicker";
this.Text = "DateTimePicker";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new DateTimePicker());
}

}
}



ASPX PAGE CODE
======================
<%@ Page language="c#" Codebehind="UseWinControl.aspx.cs"
AutoEventWireup="false" Inherits="web.playground.UseWinControl" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<html>
<head>
<title>UseWinControl</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<OBJECT id=WinControl2
classid=http:Windows.Control.Library.dll#Windows.Control.Library.DateTimePicker
height=500 width=200
VIEWASTEXT></OBJECT>

</form>

</body>
</html>
Norman Yuan
7/7/2005 12:45:57 PM
1. I think what you are taiking is not Smart Client.
2. You can embed Win Form CONTROL (or derived/customized CONTROL) in web
page (suppose the client computer has .NET framework installed), but NOT a
Win Form (or derived Form).

[quoted text, click to view]
classid=http:Windows.Control.Library.dll#Windows.Control.Library.DateTimePic
ker
[quoted text, click to view]

Chris Fink
7/7/2005 1:00:01 PM
Hi Norman,

Thanks for the response. Perhaps I am confused as to what I can and can't
do in a browser as a "smart client". In the example, the writer claims to be
able to place a DateTimePicker control on a webpage, which is what I am
attempting to do.

http://www.codeguru.com/columns/VB/article.php/c7463/

What are examples/differences between a win form and a win form control and
what allows one to be placed into a web page over the other?

Chris

[quoted text, click to view]
Norman Yuan
7/7/2005 5:45:07 PM
The major part of that article is about using Win Form CONTROLs in web page
(or web app). It is not SMART CLIENT app. As my previous reply, you use Win
Form Control in web page, not Win Form. If you take look the picture in that
article, the author created an Window User Control project and wrap up the
DateTime Picker in a Windows User Control library (i.e. the Control is a
control, not a Win Form). To do that simply start VS and create a Windows
Control Library project and then go ahead to create your control(s).

Although you can use Win Form control in web app, in general it is not a
good choice unless your web app runs under tightly controlled enveronment
(intranet, and security is not a concern... and so on). That is why the
author of that article went on to mention SMART CLIENT, which is Win Form
app, BTW.

[quoted text, click to view]

Remigiusz Samosiuk
7/8/2005 7:35:03 AM
[quoted text, click to view]

I Agree here, but as you can see in my earlier post (UserControl hosted
in IE and Control.Invoke) there are problems with background processing
when you host control in IE. If I will be able to use form instead, I
will not have such problems (because hosted control is treated as ActiveX).
But probably it will not be a problem with simple controls like
DateTimePicker.

BTW. Beware of SecurityException !!! :-) It will be your curse when you
start to do controls hosted in IE

Assembly file locked
8/26/2005 2:14:03 PM
Hi, Chris,

I'm having the same problem that you have. Have you resolve the problem?
I could not find the resolution from the following trail. I'd appreciate if
you
can let me know or other resources.

Robert

[quoted text, click to view]
Norman Yuan
8/27/2005 9:01:46 AM
I am not a fan of using Windows.Forms controls in a web page and only tried
it in my study. Here are a couple of thoughts:

1. The control should be derived from UserControl, not from Form, shouldn't
it?

2. I certianly would not use "Windows" as namespace identifier, just avoid
possible namespace conflict.

3. the "classid" atribute in <Object...> tag of the aspx page should be
pointing to a valid virtue path to the *.dll file containing the control.
The code in previous post certainly does not look like a valid virtue path:

"http:Windows.Control...."

It should look like

http://mysite/myfolder/myControls.dll#MyNamespace.MyDTPicker



[quoted text, click to view]

AddThis Social Bookmark Button