473,396 Members | 1,998 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,396 software developers and data experts.

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
Nov 17 '05 #1
2 12984
See this thread on ASP.NET forums

Modifying postback script:
http://www.asp.net/Forums/ShowPost.a...1&PostID=62695

--
Teemu Keiski
MCP, Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

Email:
jo****@aspalliance.com
"Mike Dunn" <no*************@britishland.com> wrote in message
news:02****************************@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

Nov 17 '05 #2
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" <no*************@britishland.com> wrote in message
news:02****************************@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

Nov 17 '05 #3

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

Similar topics

0
by: Frankieboy | last post by:
Where is __doPostBack-function defined? I've got an application which generates a different __doPostBack-function when the code is being run on the server compared to the one on my laptop. The...
1
by: paul reed | last post by:
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 a child form from a parent...I update the...
3
by: E | last post by:
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 at the client:...
1
by: Adrian | last post by:
I appear to be losing ViewState information when calling the __doPostBack function. I am attempting to use the showModalDialog to load a new web page which confirms that a user wishes to save a...
3
by: Marcelo | last post by:
Hello, I am trying to create a postback event, and it is working, just not calling the sub. I have a datagrid which has <asp:DataGrid id="Mensajes" ... <Columns> <asp:HyperLinkColumn ....
1
by: Jason | last post by:
Hi when you hover over a LinkButton, the window status text changes. e.g. javascript:__doPostBack('lnkNextBottom','') how do i change it so that it does not display this text? i have tried...
3
by: Steve Wonderful | last post by:
I checked the rendered html and found __doPostBack() function was not found in the html source. Is there a reason? How do I force it to be generated. The page seems to function properly for post...
1
by: Philip | last post by:
I am attempting to use the ASP.NET generated __doPostBack JavaScript function in my custom JavaScript and I can use it successfully but only after the web page is loaded and idle. I prefer to...
0
by: =?Utf-8?B?Uml0YUc=?= | last post by:
Hello. I'm maintaining a C# Web based project that has a class which adds a "Show All" / "Show By Page" functionality to a datagrid that allows paginating. This class works when there are...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.