This is a migrated thread and some comments may be shown as answers.

client side scripts

1 Answer 43 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
ehsan asked on 31 Oct 2010, 07:14 PM
<%@ 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">
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <telerik:AjaxUpdatedControl ControlID="DetailsView1" LoadingPanelID="RadAjaxLoadingPanel1" />
        <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">
                            <telerik:GridBoundColumn DataField="p_ID">
            <telerik:RadSplitBar runat="server" ID="RP" />
            <telerik:RadPane runat="server" ID="RP_DetailView">             
                    <asp:DetailsView runat="server" ID="DetailsView1"  DataSourceID="sds_Details" >
                           <asp:BoundField DataField="sh_Title" />
                                <asp:Button ID="btn_Edit" Text ="Edit" runat="server" />
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?


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 01 Nov 2010, 01:47 PM
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,
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
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question