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 [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <026f01c34637$52dcbf10$a101280a@phx.gbl> [ref] => [htmlstate] => on_nl2br [postusername] => Mike Dunn [ip] => nospammike.dunn [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> > > > 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 > >[/quote] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => <026f01c34637$52dcbf10$a101280a@phx.gbl> [htmlstate] => on_nl2br [postusername] => Teemu Keiski [ip] => joteke@aspallia [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> > > > 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 > >[/quote] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => <026f01c34637$52dcbf10$a101280a@phx.gbl> [htmlstate] => on_nl2br [postusername] => vMike [ip] => Michael.George@ [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 3 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> Overriding __doPostBack - ASP.NET General

Overriding __doPostBack - ASP.NET General

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 = doent.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 ...

  1. #1

    Default 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 =
    doent.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

  2. #2

    Default 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]jotekeaspalliance.com[/email]


    "Mike Dunn" <nospammike.dunnbritishland.com> wrote in message
    news:026f01c34637$52dcbf10$a101280aphx.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 =
    > doent.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

  3. #3

    Default 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("doent._ctl1:_ctl0;")
    html = html.Replace("doent._ctl1:_ctl0", "doent._ctl1__ctl0")
    end if
    writer.Write(html)

    End Sub

    "Mike Dunn" <nospammike.dunnbritishland.com> wrote in message
    news:026f01c34637$52dcbf10$a101280aphx.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 =
    > doent.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

Similar Threads

  1. __doPostBack generates JavaScript errors in UserControl encapsulating form
    By Stephen Miller in forum ASP.NET Building Controls
    Replies: 1
    Last Post: May 18th, 08:10 AM
  2. __doPostback method with colons problem
    By Steven Livingstone in forum ASP.NET General
    Replies: 15
    Last Post: August 28th, 12:57 AM
  3. Replies: 3
    Last Post: July 31st, 10:43 AM
  4. __doPostBack EventArgument
    By Hayato Iriumi in forum ASP.NET General
    Replies: 0
    Last Post: July 22nd, 04:36 AM
  5. Wierd Behavior of __doPostBack
    By paul reed in forum ASP.NET General
    Replies: 2
    Last Post: July 8th, 04:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •