Although the webcontrols of asp.NET are very cool. sometimes they just don't give you enough flexibility. I had the problem for a site I am making that this people have to upload huge amounts of data. It is an online tv-station. At first I tried uploading through the http post. But the uploads grew larger in size. So I went through http uploads but passed on in another thread hoping this would improve stability. It did a little bit. The second problem you are facing is the huge timeout amount you have to set on the page in order to get it to upload 180 Mb of data.
Some time passed and I still wasn't happy with the way things were going so I decided to write an ftp-client based on the library of edt in winforms to make it more stable. After all ftp = file transfer protocol ;). The database edits were done through a webservice. This was cool. And then msn comes with spaces and they had something I wanted. They can select multiple files. Every picture can be selected seperately.. .Obviously winforms but it ran in my browser. So the search starts.
1. A simple webcontrol As an example I made a calculator that can only multiply 2 values.
Please feel free to get the code below :
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Drawing;
using
System.Data;
using
System.Windows.Forms;
namespace
Koolkraft.Library.Win2Web
{
///
/// Summary description for Calculator.
///
public class Calculator : System.Windows.Forms.UserControl
{
private System.Windows.Forms.TextBox tbVal1;
private System.Windows.Forms.TextBox tbVal2;
private System.Windows.Forms.Label lblResult;
private System.Windows.Forms.Button btnMultiply;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Calculator()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
}
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region
Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.tbVal1 = new System.Windows.Forms.TextBox();
this.tbVal2 = new System.Windows.Forms.TextBox();
this.lblResult = new System.Windows.Forms.Label();
this.btnMultiply = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// tbVal1
//
this.tbVal1.Location = new System.Drawing.Point(32, 24);
this.tbVal1.Name = "tbVal1";
this.tbVal1.TabIndex = 0;
this.tbVal1.Text = "";
//
// tbVal2
//
this.tbVal2.Location = new System.Drawing.Point(32, 56);
this.tbVal2.Name = "tbVal2";
this.tbVal2.TabIndex = 1;
this.tbVal2.Text = "";
//
// lblResult
//
this.lblResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblResult.ForeColor = System.Drawing.Color.IndianRed;
this.lblResult.Location = new System.Drawing.Point(152, 104);
this.lblResult.Name = "lblResult";
this.lblResult.TabIndex = 2;
this.lblResult.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnMultiply
//
this.btnMultiply.Location = new System.Drawing.Point(152, 24);
this.btnMultiply.Name = "btnMultiply";
this.btnMultiply.Size = new System.Drawing.Size(24, 23);
this.btnMultiply.TabIndex = 3;
this.btnMultiply.Text = "x";
this.btnMultiply.Click += new System.EventHandler(this.btnMultiply_Click);
//
// Calculator
//
this.BackColor = System.Drawing.Color.Khaki;
this.Controls.Add(this.btnMultiply);
this.Controls.Add(this.lblResult);
this.Controls.Add(this.tbVal2);
this.Controls.Add(this.tbVal1);
this.Name = "Calculator";
this.Size = new System.Drawing.Size(264, 150);
this.ResumeLayout(false);
}
#endregion
private void btnMultiply_Click(object sender, System.EventArgs e)
{
double val1 = double.Parse(tbVal1.Text);
double val2 = double.Parse(tbVal2.Text);
double result = val1 * val2;
lblResult.Text = result.ToString();
}
}
}
Now that we have the usercontrol we compile it and put the compiled assembly in an accessible folder of the website. The /bin folder won't do because we don't have browse access to this folder. Next we make a page this can be html or aspx it is the same. between de body tags but an object like this <OBJECT id="mycalculator" classid="http://localhost/TestLib/Win2Web/Koolkraft.Library.Win2Web.dll#Koolkraft.Library.Win2Web.Calculator" VIEWASTEXT>