open a new window with ajax reorder list

Discussion in 'ASP .Net Web Controls' started by Haim, Jan 29, 2009.

  1. Haim

    Haim Guest

    I have a web page with the reorderlist web control containing a link button
    in the item template. The result of the click is dependent upon a radio
    button selection made prior to the link button click. The user can update a
    text field depending upon the value of the link button, or I would like to
    open a different aspx page in a new window (Code Behind of Link button event
    attached). I have no problems updating the literal field, and only the
    literal field is refreshed. But when I try to open a new window I get the
    following script error on the page:
    "Sys.WebForms.pagerequestmanagerParserErrorException: The message received
    from the server could not be parsed."
    If I do not use an update panel, the code works fine. Or if I add a
    triggers section to the update panel the code will also work, but I loose
    the partial refresh when I update the text field (entire page refreshes).
    This is my first attempt at an Ajax enabled web page. I assume proper
    javascript will work better than my code below. Can someone give me some
    hints how to capture the click in javascript so that I can run the code?



    Page Source
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel2"
    runat="server">
    <ContentTemplate>

    <asp:DropDownList ID="PanelDDl" runat="server" Height="41px"
    Width="202px"
    AutoPostBack="True" DataSourceID="PanelDS"
    DataTextField="PanelFullName"
    DataValueField="OldPanelShortName">
    </asp:DropDownList>
    <cc1:DropDownExtender ID="PanelDDl_DropDownExtender" runat="server"
    DynamicServicePath="" Enabled="True"
    TargetControlID="PanelDDl" >
    </cc1:DropDownExtender>
    <cc1:ReorderList ID="ReorderList1" runat="server"
    PostBackOnReorder="False" Width="196px"
    DataSourceID="PanelListds"
    DataKeyField="Counter" >
    <ItemTemplate>
    <asp:LinkButton ID="LinkButton1"
    runat="server" text='<%# Eval("Counter")%>'
    onclick="LinkButton1_Click"></asp:LinkButton>
    </ItemTemplate>
    <DragHandleTemplate>&nbsp;</DragHandleTemplate>
    (won't work at all without this template)
    </cc1:ReorderList>
    <asp:ObjectDataSource ID="PanelListds"
    runat="server"
    OldValuesParameterFormatString="original_{0}"
    SelectMethod="GetData"
    TypeName="ProposalCountersTableAdapters.GetProposalforAbstractbyPanelTableAdapter">
    <SelectParameters>
    <asp:ControlParameter ControlID="PanelDDl"
    Name="panel"
    PropertyName="SelectedValue"
    Type="String" />
    </SelectParameters>
    </asp:ObjectDataSource>
    </ContentTemplate>
    (If I put a trigger here, the code will open a new window, but I
    get a full refresh of this page for the other functions.)
    </asp:UpdatePanel>

    Code Behind for Linkbutton
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As
    System.EventArgs)
    Dim myref As New GetsinglePanel.GetReview
    Select Case RadioButtonList1.SelectedValue
    Case "Reviews"
    ' Updates literal field on page - this works in all cases
    Case "Proposal"
    'Want to open an aspx page in a new window based on value
    clicked in list
    Dim myscript As String
    myscript = "<script language='javascript'
    type='text/javascript'>"
    myscript += "window.open(" & _
    "'DLProp.aspx?counter=" & sender.text &
    "','win','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1');"
    myscript += "</script>"
    Me.ClientScript.RegisterClientScriptBlock(Me.GetType(),
    "myscript", myscript)
    or
    System.Web.HttpContext.Current.Response.Write(myscript)
    End Select

    End Sub
    Haim, Jan 29, 2009
    #1
    1. Advertising

  2. Hello Haim,

    Based on my understanding, you have a DropDownList to handle the
    LinkButton functionality. But it didn't execute the JavaScript you
    registered from the server-side. If I have misunderstood you, please feel
    free to let me know.

    I think the problem is that script register is not in the right way. Within
    UpdatePanel, we can't use Response.Write or Server.Transfer, otherwise we
    will encounter the error
    "Sys.WebForms.PageRequestManagerParserErrorException" . If you want to get
    further information about it, you can check the below link:
    http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagereque
    stmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx

    In this case, neither Response.Write nor ClientScript can be used to
    register the JavaScript to the client. I suggest you use
    ScriptManager.RegisterStartupScript to do it. It will work within
    UpdatePanel.

    Please try to modify the existing code as following to see if it works:

    Case "Proposal"
    Dim myscript As String
    myscript = "window.open(" & _
    "'DLProp.aspx?counter=" & sender.Text &
    "','win','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1
    ,resizable=1');"
    ScriptManager. RegisterStartupScript(Me,Me.GetType(),
    "myscript", myscript, True)



    Sincerely,

    Vince Xu

    Microsoft Online Support

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    MSDN Managed Newsgroup support offering is for non-urgent issues where an
    initial response from the community or a Microsoft Support Engineer within
    2 business day is acceptable. Please note that each follow up response may
    take approximately 2 business days as the support professional working with
    you may need further investigation to reach the most efficient resolution.
    The offering is not appropriate for situations that require urgent,
    real-time or phone-based interactions. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    Vince Xu [MSFT], Jan 30, 2009
    #2
    1. Advertising

  3. Haim

    Haim Guest

    Dear Vince,
    Thank you very much for your informative and helpful post. Your code solved
    this problem.

    Haim
    --
    Haim Katz
    BARD


    "Vince Xu [MSFT]" wrote:

    > Hello Haim,
    >
    > Based on my understanding, you have a DropDownList to handle the
    > LinkButton functionality. But it didn't execute the JavaScript you
    > registered from the server-side. If I have misunderstood you, please feel
    > free to let me know.
    >
    > I think the problem is that script register is not in the right way. Within
    > UpdatePanel, we can't use Response.Write or Server.Transfer, otherwise we
    > will encounter the error
    > "Sys.WebForms.PageRequestManagerParserErrorException" . If you want to get
    > further information about it, you can check the below link:
    > http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagereque
    > stmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx
    >
    > In this case, neither Response.Write nor ClientScript can be used to
    > register the JavaScript to the client. I suggest you use
    > ScriptManager.RegisterStartupScript to do it. It will work within
    > UpdatePanel.
    >
    > Please try to modify the existing code as following to see if it works:
    >
    > Case "Proposal"
    > Dim myscript As String
    > myscript = "window.open(" & _
    > "'DLProp.aspx?counter=" & sender.Text &
    > "','win','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1
    > ,resizable=1');"
    > ScriptManager. RegisterStartupScript(Me,Me.GetType(),
    > "myscript", myscript, True)
    >
    >
    >
    > Sincerely,
    >
    > Vince Xu
    >
    > Microsoft Online Support
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >
    > MSDN Managed Newsgroup support offering is for non-urgent issues where an
    > initial response from the community or a Microsoft Support Engineer within
    > 2 business day is acceptable. Please note that each follow up response may
    > take approximately 2 business days as the support professional working with
    > you may need further investigation to reach the most efficient resolution.
    > The offering is not appropriate for situations that require urgent,
    > real-time or phone-based interactions. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    > ==================================================
    >
    >
    Haim, Feb 1, 2009
    #3
    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. JohnE

    reorder list

    JohnE, Feb 6, 2010, in forum: ASP .Net
    Replies:
    2
    Views:
    746
    JohnE
    Feb 6, 2010
  2. imperialguy
    Replies:
    0
    Views:
    264
    imperialguy
    May 8, 2011
  3. Gordon
    Replies:
    3
    Views:
    289
    Steven Burn
    Apr 16, 2004
  4. PC HUA
    Replies:
    2
    Views:
    394
    PC HUA
    May 19, 2004
  5. Replies:
    1
    Views:
    225
Loading...

Share This Page