Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Creating custom form in Asp.NET 2.0

 
Thread Tools Search this Thread
Old 12-14-2005, 12:02 PM   #1
Default 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



=?Utf-8?B?VGFiaQ==?=
  Reply With Quote
Old 12-14-2005, 01:58 PM   #2
Kevin Spencer
 
Posts: n/a
Default Re: Creating custom form in Asp.NET 2.0

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" <> wrote in message
news:9843FDFA-48AB-4842-A67A-...
> 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
>



  Reply With Quote
Old 12-14-2005, 02:16 PM   #3
=?Utf-8?B?VGFiaQ==?=
 
Posts: n/a
Default Re: Creating custom form in Asp.NET 2.0

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" <> wrote in message
> news:9843FDFA-48AB-4842-A67A-...
> > 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
> >

>
>
>

  Reply With Quote
Old 12-14-2005, 05:59 PM   #4
Kevin Spencer
 
Posts: n/a
Default Re: Creating custom form in Asp.NET 2.0

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" <> wrote in message
news:3550CA34-609D-46D7-8DAA-...
> 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" <> wrote in message
>> news:9843FDFA-48AB-4842-A67A-...
>> > 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
>> >

>>
>>
>>



  Reply With Quote
Old 03-22-2007, 07:02 PM   #5
acceleware
Junior Member
 
Join Date: Mar 2007
Posts: 1
Default Find a resolution?

Hello, I'm also having the same trouble with Designer for the ActionlessForm. Did you find a solution?

Thanks!
acceleware is offline   Reply With Quote
Old 04-22-2008, 12:24 PM   #6
habz
Junior Member
 
Join Date: Apr 2008
Posts: 1
Default actionlessform

did anybody have solution for that?
habz is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump