Re: Wrap a div tag around viewstate output

From: Henrik Larsen (henrik.larsen_at_nospam.com)
Date: 09/19/04


Date: Sun, 19 Sep 2004 22:58:39 +0200

Got it! If someone is interested:

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

Dim re As Regex

re = New Regex("(<form.*?__aspnetForm.*?>)",
System.Text.RegularExpressions.RegexOptions.IgnoreCase)

Dim sb As StringBuilder = New StringBuilder

Dim sw As StringWriter = New StringWriter(sb)

Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)

MyBase.Render(hw)

Dim html As String = sb.ToString()

html = re.Replace(html, New MatchEvaluator(AddressOf ViewStateMatch))

writer.Write(html)

End Sub

Private Function ViewStateMatch(ByVal m As Match) As String

Return "<div id=""spacer""></div><div id=""wrapper"">" & m.ToString()

End Function

"Eliyahu Goldin" <removemeegoldin@monarchmed.com> skrev i melding
news:OKxQBOlnEHA.3352@TK2MSFTNGP15.phx.gbl...
> If I understand you correctly, all you want to do is to apply a style to
> these inputs. If so, you should be able to do it on client-side with
> javascript. Use method getElementsByName to find the elements and just set
> their class property to your class name.
>
> Eliyahu
>
> "Henrik Larsen" <henrik.larsen@nospam.com> wrote in message
> news:elNCbClnEHA.3968@TK2MSFTNGP11.phx.gbl...
> > Hello!
> >
> > The problem is, when you build a page entirely in css in a certain way
> > hidden inputs affect the layout
> > of the page. I have someone checking out if it can be handled in css but
> it
> > doesn't look very promising.
> >
> > I was thinking that maybe it was possible to write the div wrapper on
> > prerender or something. One solution would
> > maybe to add the </div> tag just behind the <form...> tag in the code
and
> > then the generated inputs are written to the
> > output and then before it is sendt back to the client add the <div> tag
by
> > referensing the forms id somehow:
> >
> > 1. In code, before any rendering: <form id="form1"></div>....
> > 2. After it is rendered by asp.net: <form id="form1"><input.....></div>
> > 3. Insert befor sendt to client: <form id="form1"><div><input...></div>
> >
> > I am sure it is possible but how?
> >
> > Marius
> >
> > "Eliyahu Goldin" <removemeegoldin@monarchmed.com> skrev i melding
> > news:OLycIthnEHA.2764@TK2MSFTNGP11.phx.gbl...
> > > Since these inputs are not in the source page code, it is hard to
> imagine
> > > how you can affect their generation.
> > >
> > > What is the problem in the first place? What do you mean by
"destroying
> > the
> > > css code"?
> > >
> > > Eliyahu
> > >
> > > "Henrik Larsen" <henrik.larsen@nospam.com> wrote in message
> > > news:%23yzhK5cnEHA.2172@TK2MSFTNGP10.phx.gbl...
> > > > Hello!
> > > >
> > > > The hidden controls of asp.net destroys the css code in a page I
have
> > > made:
> > > >
> > > > I wonder; how can I change this;
> > > >
> > > > <input type="hidden" name="__EVENTTARGET" value="" />
> > > > <input type="hidden" name="__EVENTARGUMENT" value="" />
> > > > <input type="hidden" name="__VIEWSTATE" value="xxx" />
> > > >
> > > > to
> > > >
> > > > <div>
> > > > <input type="hidden" name="__EVENTTARGET" value="" />
> > > > <input type="hidden" name="__EVENTARGUMENT" value="" />
> > > > <input type="hidden" name="__VIEWSTATE" value="xxx" />
> > > > </div>
> > > >
> > > > Thanks for any help
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages