473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Creating custom form in Asp.NET 2.0

Hi,

I have just created a class that removes action attribute from HtmlForm. The
code looks like here.

namespace ComIT.Applications.Common
{
public class Form : System.Web.UI.HtmlControls.HtmlForm
{
protected override void RenderAttributes(HtmlTextWriter writer)
{
writer.WriteAttribute("name", this.Name);
base.Attributes.Remove("name");

writer.WriteAttribute("method", this.Method);
base.Attributes.Remove("method");

this.Attributes.Render(writer);

base.Attributes.Remove("action");

if (base.ID != null)
writer.WriteAttribute("id", base.ClientID);
}
}
}

I have registered it in my ASPX page. It looks like this.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%@ Register TagPrefix="ca" Namespace="ComIT.Applications.Common"
Assembly="ComIT.Applications.Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title id="PageTitle" runat="server">Default</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
</head>
<body>
<ca:Form id="form1" method="post" runat="server">
</ca:Form>
</body>
</html>

When I switch my ASPX page to design mode, it shows following error.

Unable to cast object of type
'System.Web.Ui.Design.HtmlIntrinsicControlDesigner ' to type
'System.Web.Ui.Design.ControlDesigner'.
Why is this error coming? Am I doing anything wrong?
Thanks in advanced.
Tabi

Dec 14 '05 #1
3 4128
Well, my first question would have to be, why do you want to do this at all?
You are breaking the object model of a WebForm by doing so.

The exception seems to indicate that the Designer for an HtmlForm is running
into a problem with your override. Designers use various methods of the
Controls they design, particularly those methods which render the Control in
the Page, to render the Control at design-time. As I have no way of peeking
inside the Designer code for the HtmlForm Control, that is all I can say.
But it does beg the question I started with.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Tabi" <Ta**@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
Hi,

I have just created a class that removes action attribute from HtmlForm.
The
code looks like here.

namespace ComIT.Applications.Common
{
public class Form : System.Web.UI.HtmlControls.HtmlForm
{
protected override void RenderAttributes(HtmlTextWriter writer)
{
writer.WriteAttribute("name", this.Name);
base.Attributes.Remove("name");

writer.WriteAttribute("method", this.Method);
base.Attributes.Remove("method");

this.Attributes.Render(writer);

base.Attributes.Remove("action");

if (base.ID != null)
writer.WriteAttribute("id", base.ClientID);
}
}
}

I have registered it in my ASPX page. It looks like this.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%@ Register TagPrefix="ca" Namespace="ComIT.Applications.Common"
Assembly="ComIT.Applications.Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title id="PageTitle" runat="server">Default</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
</head>
<body>
<ca:Form id="form1" method="post" runat="server">
</ca:Form>
</body>
</html>

When I switch my ASPX page to design mode, it shows following error.

Unable to cast object of type
'System.Web.Ui.Design.HtmlIntrinsicControlDesigner ' to type
'System.Web.Ui.Design.ControlDesigner'.
Why is this error coming? Am I doing anything wrong?
Thanks in advanced.
Tabi

Dec 14 '05 #2
Dear Kevin,

Thanks for answer. I am actually using url rewriting as described at msdn
http://msdn.microsoft.com/library/de...lrewriting.asp

Please check out the "Handling Postbacks" section. I am using 100% same
code. The problem is that this code does not work in asp.net 2.0.

Is there any other way to work around this in asp.net 2.0?

Thanx once again.

Tabi
"Kevin Spencer" wrote:
Well, my first question would have to be, why do you want to do this at all?
You are breaking the object model of a WebForm by doing so.

The exception seems to indicate that the Designer for an HtmlForm is running
into a problem with your override. Designers use various methods of the
Controls they design, particularly those methods which render the Control in
the Page, to render the Control at design-time. As I have no way of peeking
inside the Designer code for the HtmlForm Control, that is all I can say.
But it does beg the question I started with.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Tabi" <Ta**@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
Hi,

I have just created a class that removes action attribute from HtmlForm.
The
code looks like here.

namespace ComIT.Applications.Common
{
public class Form : System.Web.UI.HtmlControls.HtmlForm
{
protected override void RenderAttributes(HtmlTextWriter writer)
{
writer.WriteAttribute("name", this.Name);
base.Attributes.Remove("name");

writer.WriteAttribute("method", this.Method);
base.Attributes.Remove("method");

this.Attributes.Render(writer);

base.Attributes.Remove("action");

if (base.ID != null)
writer.WriteAttribute("id", base.ClientID);
}
}
}

I have registered it in my ASPX page. It looks like this.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%@ Register TagPrefix="ca" Namespace="ComIT.Applications.Common"
Assembly="ComIT.Applications.Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title id="PageTitle" runat="server">Default</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
</head>
<body>
<ca:Form id="form1" method="post" runat="server">
</ca:Form>
</body>
</html>

When I switch my ASPX page to design mode, it shows following error.

Unable to cast object of type
'System.Web.Ui.Design.HtmlIntrinsicControlDesigner ' to type
'System.Web.Ui.Design.ControlDesigner'.
Why is this error coming? Am I doing anything wrong?
Thanks in advanced.
Tabi


Dec 14 '05 #3
Hi Tabi,

My apologies. You are correct. In any case, if you're having problems with
the Designer, I think you will have to write a custom Designer for your
form, or don't switch to Design view. It's the Designer that is throwing an
exception.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Tabi" <Ta**@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com...
Dear Kevin,

Thanks for answer. I am actually using url rewriting as described at msdn
http://msdn.microsoft.com/library/de...lrewriting.asp

Please check out the "Handling Postbacks" section. I am using 100% same
code. The problem is that this code does not work in asp.net 2.0.

Is there any other way to work around this in asp.net 2.0?

Thanx once again.

Tabi
"Kevin Spencer" wrote:
Well, my first question would have to be, why do you want to do this at
all?
You are breaking the object model of a WebForm by doing so.

The exception seems to indicate that the Designer for an HtmlForm is
running
into a problem with your override. Designers use various methods of the
Controls they design, particularly those methods which render the Control
in
the Page, to render the Control at design-time. As I have no way of
peeking
inside the Designer code for the HtmlForm Control, that is all I can say.
But it does beg the question I started with.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Tabi" <Ta**@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
> Hi,
>
> I have just created a class that removes action attribute from
> HtmlForm.
> The
> code looks like here.
>
> namespace ComIT.Applications.Common
> {
> public class Form : System.Web.UI.HtmlControls.HtmlForm
> {
> protected override void RenderAttributes(HtmlTextWriter writer)
> {
> writer.WriteAttribute("name", this.Name);
> base.Attributes.Remove("name");
>
> writer.WriteAttribute("method", this.Method);
> base.Attributes.Remove("method");
>
> this.Attributes.Render(writer);
>
> base.Attributes.Remove("action");
>
> if (base.ID != null)
> writer.WriteAttribute("id", base.ClientID);
> }
> }
> }
>
> I have registered it in my ASPX page. It looks like this.
>
> <%@ Page Language="C#" AutoEventWireup="true"
> CodeFile="Default.aspx.cs"
> Inherits="_Default" %>
> <%@ Register TagPrefix="ca" Namespace="ComIT.Applications.Common"
> Assembly="ComIT.Applications.Common" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title id="PageTitle" runat="server">Default</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1"
> />
> <meta http-equiv="Content-Script-Type" content="text/javascript" />
> <meta http-equiv="Content-Style-Type" content="text/css" />
> <meta http-equiv="imagetoolbar" content="no" />
> </head>
> <body>
> <ca:Form id="form1" method="post" runat="server">
> </ca:Form>
> </body>
> </html>
>
> When I switch my ASPX page to design mode, it shows following error.
>
> Unable to cast object of type
> 'System.Web.Ui.Design.HtmlIntrinsicControlDesigner ' to type
> 'System.Web.Ui.Design.ControlDesigner'.
>
>
> Why is this error coming? Am I doing anything wrong?
>
>
> Thanks in advanced.
>
>
> Tabi
>


Dec 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carlos Kirkconnell | last post by:
When printing, there is a definition for a Custom paper size, the custom paper size can be setted programatically and everything is supposed to work normally. But in windows 2000 and xp, the user...
4
by: Alvo von Cossel I | last post by:
hi, i have been asked to make a good-looking app for a friend. i have an options form with a big tabstrip in it. 1. how can i customize it e.g. change from the standard system style...
3
by: Kyle Fitzgerald | last post by:
I've started a web control library project and can build my own controls to add to the toolbox in the .NET environment. The problem I'm having is I want to create a control just like the HTML...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
0
by: shanthsp2002 | last post by:
well friends i have a small tip here which may be helpfull for u there may be situations where we need to use a customized dilogue box while doveloping setup and dyployment project, so u can do...
10
by: Jake Forson | last post by:
Hi there, I'd like to re-create a form given only its resource file. I was going to simply read the resource file and re-create the "Form" object and all its controls as found in this file...
0
by: zyberboy | last post by:
I am a beginner in programming(c#),and this is my first post in this forum. I want to know how to create custom shaped windows form in vs2005 express edition. I was able to create a oval shaped form...
5
by: Doc John | last post by:
I need to create several Windows Forms and I'm thinking of creating a base Form from which I can derive all Forms. Is it possible to include something in that Base Form so that all Forms I create...
0
by: str1ker | last post by:
Hi, I've been working with C# for quite a while now, and I'd like to start creating programs which aren't the usual old regular Windows controls. I'd like to have controls which are graphically...
1
by: deepapanch | last post by:
Hi All: I am new to C#. Have created a simple outlook add-in, which adds a command bar in Outlook. On click of the button, I would like to load the a simple dialog with a Text Box and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.