Ask a Question related to ASP.NET General, Design and Development.
-
Mike Dunn #1
Overriding __doPostBack
I would like to change the name of the _doPostBack
function emmitted by the ASP.NET framework to prefix it
with an ordinal number i.e. the page should show
<script language="javascript">
<!--
function _369__doPostBack(eventTarget,
eventArgument) {
var theform =
document.frmRetailTenantGadget;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value =
eventArgument;
theform.submit();
}
// -->
</script>
The reason for this is I am working on a portal server and
the output form multiple aspx pages ends up in the same
HTML page. Multiple declarations of __doPostBack cause a
problem in the page. I have found one way to do this is to
override the page render event thus
protected override void Render
(HtmlTextWriter writer)
{
StringBuilder stringBuilder = new
StringBuilder();
StringWriter stringWriter = new
StringWriter(stringBuilder);
HtmlTextWriter htmlWriter = new
HtmlTextWriter(stringWriter);
base.Render(htmlWriter);
string html =
stringBuilder.ToString();
// Prepend postback scripts with
gadget ids
html = html.Replace
("__doPostBack", "_" + GadgetId + "__doPostBack");
writer.Write(html);
}
This works but I believe it could cause a problem with
performance as the find replace is an expensive operation.
Does anyone know a better (faster? more elegant?) way of
doing this
Regards
Mike
Mike Dunn Guest
-
__doPostBack generates JavaScript errors in UserControl encapsulating form
I have a form shared by several aspx pages. It's the only form appearing on the pages, so I though I would encapsulate the form in a User Control... -
__doPostback method with colons problem
I am running into the "colon in javascript" problem as discussed here http://www.bdragon.com/entries/000324.shtml. Basically, i have nested... -
__doPostBack code block not being generated by asp.net page
I have 2 aspx pages... neither of which do anything out of the ordinary. One of the pages automatically generates this block of code when viewed... -
__doPostBack EventArgument
Hello, guys. I have this javascript to invoke serverside event that is attached to a hidden Button. ... -
Wierd Behavior of __doPostBack
Hello, I am having some weird behavior between two machines...one which is running the 1.1 framework and one which is running 1.0. After opening... -
Teemu Keiski #2
Re: Overriding __doPostBack
See this thread on ASP.NET forums
Modifying postback script:
[url]http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=62695[/url]
--
Teemu Keiski
MCP, Designer/Developer
Mansoft tietotekniikka Oy
[url]http://www.mansoft.fi[/url]
ASP.NET Forums Moderator, [url]www.asp.net[/url]
AspAlliance Columnist, [url]www.aspalliance.com[/url]
Email:
[email]joteke@aspalliance.com[/email]
"Mike Dunn" <nospammike.dunn@britishland.com> wrote in message
news:026f01c34637$52dcbf10$a101280a@phx.gbl...> I would like to change the name of the _doPostBack
> function emmitted by the ASP.NET framework to prefix it
> with an ordinal number i.e. the page should show
> <script language="javascript">
> <!--
> function _369__doPostBack(eventTarget,
> eventArgument) {
> var theform =
> document.frmRetailTenantGadget;
> theform.__EVENTTARGET.value = eventTarget;
> theform.__EVENTARGUMENT.value =
> eventArgument;
> theform.submit();
> }
> // -->
>
> </script>
> The reason for this is I am working on a portal server and
> the output form multiple aspx pages ends up in the same
> HTML page. Multiple declarations of __doPostBack cause a
> problem in the page. I have found one way to do this is to
> override the page render event thus
>
> protected override void Render
> (HtmlTextWriter writer)
> {
> StringBuilder stringBuilder = new
> StringBuilder();
> StringWriter stringWriter = new
> StringWriter(stringBuilder);
> HtmlTextWriter htmlWriter = new
> HtmlTextWriter(stringWriter);
>
> base.Render(htmlWriter);
>
> string html =
> stringBuilder.ToString();
>
> // Prepend postback scripts with
> gadget ids
> html = html.Replace
> ("__doPostBack", "_" + GadgetId + "__doPostBack");
>
> writer.Write(html);
> }
>
> This works but I believe it could cause a problem with
> performance as the find replace is an expensive operation.
>
> Does anyone know a better (faster? more elegant?) way of
> doing this
>
> Regards
>
> Mike
>
>
Teemu Keiski Guest
-
vMike #3
Re: Overriding __doPostBack
Another possible solution (not mine) but it works. I don't know how much
this slows things down, but it works well for replacing items in the output.
I use this to fix the Netscape bug in 1.1, but you could use it for other
things.
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
Dim _stringBuilder As StringBuilder = New StringBuilder()
Dim _stringWriter As StringWriter = New StringWriter(_stringBuilder)
Dim _htmlWriter As HtmlTextWriter = New HtmlTextWriter(_stringWriter)
MyBase.Render(_htmlWriter)
Dim html As String = _stringBuilder.ToString()
Dim start As Integer = html.IndexOf("document._ctl1:_ctl0;")
html = html.Replace("document._ctl1:_ctl0", "document._ctl1__ctl0")
end if
writer.Write(html)
End Sub
"Mike Dunn" <nospammike.dunn@britishland.com> wrote in message
news:026f01c34637$52dcbf10$a101280a@phx.gbl...> I would like to change the name of the _doPostBack
> function emmitted by the ASP.NET framework to prefix it
> with an ordinal number i.e. the page should show
> <script language="javascript">
> <!--
> function _369__doPostBack(eventTarget,
> eventArgument) {
> var theform =
> document.frmRetailTenantGadget;
> theform.__EVENTTARGET.value = eventTarget;
> theform.__EVENTARGUMENT.value =
> eventArgument;
> theform.submit();
> }
> // -->
>
> </script>
> The reason for this is I am working on a portal server and
> the output form multiple aspx pages ends up in the same
> HTML page. Multiple declarations of __doPostBack cause a
> problem in the page. I have found one way to do this is to
> override the page render event thus
>
> protected override void Render
> (HtmlTextWriter writer)
> {
> StringBuilder stringBuilder = new
> StringBuilder();
> StringWriter stringWriter = new
> StringWriter(stringBuilder);
> HtmlTextWriter htmlWriter = new
> HtmlTextWriter(stringWriter);
>
> base.Render(htmlWriter);
>
> string html =
> stringBuilder.ToString();
>
> // Prepend postback scripts with
> gadget ids
> html = html.Replace
> ("__doPostBack", "_" + GadgetId + "__doPostBack");
>
> writer.Write(html);
> }
>
> This works but I believe it could cause a problem with
> performance as the find replace is an expensive operation.
>
> Does anyone know a better (faster? more elegant?) way of
> doing this
>
> Regards
>
> Mike
>
>
vMike Guest



Reply With Quote

