auto generated javascript function __doPostBack(eventTarget, eventArgument) - edit the function name

Discussion in 'ASP .Net Datagrid Control' started by TJ, Jun 15, 2006.

  1. TJ

    TJ Guest

    Is it possible to edit the auto generated javascript function names? I'm
    working in a Plumtree portal and I have two portlets on the same page using
    a datagrid control. The paging links from the first grid are causing
    postback for the second grid that's further down the page. Long story
    short, whichever grid is rendered last on a page is the one that responds to
    grid postback events such as paging or column sorting.

    Is there a way I can edit the javascript _doPostBack function name so I can
    give each datagrid their own unique functions to call?
     
    TJ, Jun 15, 2006
    #1
    1. Advertising

  2. Hi,

    Thank you for your post.

    Based on my understanding, the question is: you're using two portlets on
    the same page which both contains a datagrid control, and when you clicking
    on a link in the first grid, the event is actually handled by the second
    grid. If I've misunderstood anything, please feel free to post here.

    First I don't think it's likely caused by the javascript function name,
    it's the control id argument in the function call that determines which
    control's event gets fired.

    And if the portlet control implements INamingContainer interface (it should
    if it currently doesn't), it will create a new ID namespace within a Page
    object's control hierarchy.

    For example, we can create a UserControl which contains a DataGrid control
    named "grid1", and then we add 2 instances of this UserControl on a page,
    the postback link would be:

    javascript:__doPostBack('WebUserControl1$grid1$ctl02$ctl01','')

    It's because UserControl implemented INamingContainer interface which will
    guarantee that its internal controls will have unique id in the Page
    control hierarchy.


    Regards,
    Walter Wang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], Jun 16, 2006
    #2
    1. Advertising

  3. TJ

    TJ Guest

    You grasped the situation perfectly, and I agree w/ you that it should work
    based on unique id's per grid. But alas that's how I have it configured and
    yet it's still funky. Unfortunately, the Plumtree Portal (4.5WS - barely
    equipped to handle .net portlets) just blasts out each web app (portlet) in
    its entirety and doesn't handle much else for you. So each portlet has it's
    own <form></form> tags on it and things can get weird if web apps are
    sharing similar .net auto generated javascript - i.e. Plumtree really needs
    uniquely named javascript functions or possible clashes can occur. But I
    digress, I think your explanation should prevail, yet it doesn't. I have
    one grid named DataGrid1 and another named RadGrid1. Even the two
    javascript functions showing up in the same page should be able to handle
    this...it doesn't. : ( Here is the relevant text from a basic 'view
    source' of the page.

    <script language="javascript" type="text/javascript">
    <!--
    function __doPostBack(eventTarget, eventArgument) {
    var theform;
    if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
    theform = document.Form1;
    }
    else {
    theform = document.forms["Form1"];
    }
    theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
    theform.__EVENTARGUMENT.value = eventArgument;
    theform.submit();
    }
    // -->
    </script>
    <form name="Form1">
    <table id="DataGrid1">
    <tr>
    <td><span>1</span>&nbsp;<a
    href="javascript:__doPostBack('DataGrid1$_ctl14$_ctl1','')">2</a></td>
    </tr>
    </table>
    </form>

    <script language="javascript" type="text/javascript">
    <!--
    function __doPostBack(eventTarget, eventArgument) {
    var theform;
    if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
    theform = document.Form2;
    }
    else {
    theform = document.forms["Form2"];
    }
    theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
    theform.__EVENTARGUMENT.value = eventArgument;
    theform.submit();
    }
    // -->
    </script>
    <form name="Form2">
    <div id="RadGrid1">
    <table cellspacing="0" border="0" id="RadGrid1__ctl1">
    <thead>
    <tr>
    <th class="GridHeader"><span title="Click here to sort"
    onclick="javascript:__doPostBack('RadGrid1$_ctl1$_ctl2$_ctl0$_ctl0','')">Client
    Name</span>
    </th>
    </tr>
    </thead>
    </table>
    </div>
    </form>


    "Walter Wang [MSFT]" <> wrote in message
    news:...
    >
    > Hi,
    >
    > Thank you for your post.
    >
    > Based on my understanding, the question is: you're using two portlets on
    > the same page which both contains a datagrid control, and when you
    > clicking
    > on a link in the first grid, the event is actually handled by the second
    > grid. If I've misunderstood anything, please feel free to post here.
    >
    > First I don't think it's likely caused by the javascript function name,
    > it's the control id argument in the function call that determines which
    > control's event gets fired.
    >
    > And if the portlet control implements INamingContainer interface (it
    > should
    > if it currently doesn't), it will create a new ID namespace within a Page
    > object's control hierarchy.
    >
    > For example, we can create a UserControl which contains a DataGrid control
    > named "grid1", and then we add 2 instances of this UserControl on a page,
    > the postback link would be:
    >
    > javascript:__doPostBack('WebUserControl1$grid1$ctl02$ctl01','')
    >
    > It's because UserControl implemented INamingContainer interface which will
    > guarantee that its internal controls will have unique id in the Page
    > control hierarchy.
    >
    >
    > Regards,
    > Walter Wang
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    TJ, Jun 21, 2006
    #3
  4. Hi,

    Thank you for your update.

    Now I get the whole picture of the problem. I don't think this is supported
    in ASP.NET.

    As a side note, is it possible to use some static html pages which
    basically wraps the aspx page in iframe, then use those html pages as
    portlet?


    Regards,
    Walter Wang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], Jun 22, 2006
    #4
  5. TJ

    TJ Guest

    hehe..fascinating idea w/ the iframe, that might have to be the solution.
    Thx for your patience and your fast responses.


    "Walter Wang [MSFT]" <> wrote in message
    news:p...
    > Hi,
    >
    > Thank you for your update.
    >
    > Now I get the whole picture of the problem. I don't think this is
    > supported
    > in ASP.NET.
    >
    > As a side note, is it possible to use some static html pages which
    > basically wraps the aspx page in iframe, then use those html pages as
    > portlet?
    >
    >
    > Regards,
    > Walter Wang
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    TJ, Jun 27, 2006
    #5
  6. Hi,

    Thank you for your update.

    Please let me know whether or not the suggestion works.

    Have a nice day!


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], Jun 27, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hayato Iriumi

    __doPostBack EventArgument

    Hayato Iriumi, Jul 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    728
    Hayato Iriumi
    Jul 22, 2003
  2. E
    Replies:
    3
    Views:
    4,227
    John Saunders
    Jul 31, 2003
  3. MeDhanush
    Replies:
    1
    Views:
    914
    Natty Gur
    Aug 28, 2003
  4. linkswanted
    Replies:
    1
    Views:
    922
  5. JohnE
    Replies:
    2
    Views:
    2,086
    JohnE
    Sep 22, 2009
Loading...

Share This Page