client side scripts

2 posts, 0 answers
  1. ehsan
    ehsan avatar
    27 posts
    Member since:
    Apr 2008

    Posted 31 Oct 2010 Link to this post

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_Main" runat="Server">
        <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" />
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server" ..../>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="DetailsView1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadSplitter runat="server" ID="RadSplitter1">
                <telerik:RadPane runat="server" ID="RadPane_Page_Grid">
                    <telerik:RadGrid runat="server" ID="RadGrid1"  OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged" ...>
                        <MasterTableView DataKeyNames="p_ID">
                            <Columns>
                                <telerik:GridBoundColumn DataField="p_ID">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </telerik:RadPane>
                <telerik:RadSplitBar runat="server" ID="RP" />
                <telerik:RadPane runat="server" ID="RP_DetailView">             
                        <asp:DetailsView runat="server" ID="DetailsView1"  DataSourceID="sds_Details" >
                            <Fields>
                               <asp:BoundField DataField="sh_Title" />
                            </Fields>
                            <HeaderTemplate>
                                    <asp:Button ID="btn_Edit" Text ="Edit" runat="server" />
                            </HeaderTemplate>
                        </asp:DetailsView>
                </telerik:RadPane>
            </telerik:RadSplitter>
    </asp:Content>
    hi all,
    i have (datagrid + detailsview) , my datagrid is ajaxified to update detailview on RadGrid1_SelectedIndexChanged  event :
    i have one button in my detailview that affected in this event:
    protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
       {
     Button btn = (Button)DetailsView1.FindControl("btn_Edit");
           btn.OnClientClick = "alert('some text here...');";
     }
    at first page load and selecting one row of grid,my detailsview updates, and by clicking on btn_Edit client side alert displayed, but on clicking again on this button(btn_Edit) client side alert not function again!


    can u help me?

    tnx.
  2. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 01 Nov 2010 Link to this post

    Hello Ehsan,

    I assume that when you click the btn_Edit a postback is occurred, however the code into the SelectedIndexChanged is not executed and the event handler function is not attached to the button's OnClientClick event. To achieve the desired functionality you need to attach the handler to the button's OnClientClick event, on every postback. Additionally if you do not want to execute any server side code when the btn_Edit is clicked you could add "return false;" clause on the end of the OnClientClick handler. This will prevent the postback:
    protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
    {
     Button btn = (Button)DetailsView1.FindControl("btn_Edit");
           btn.OnClientClick = "alert('some text here...'); return false;";
    }

    Please give it try and let me know if you experience any problems.

    Kind regards,
    Radoslav
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top