Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
JavaScript Alert in not working in _RowUpdating event
posted

I have wriiten alert message as below in my webdatagrid_rowUpdating event.

if(APUtility.ToDateTime(e.Values["PTOStartDate"]) < System.DateTime.Now || APUtility.ToDateTime(e.Values["PTOSEndDate"]) < System.DateTime.Now)

{

String Message = PtoPopUpMessages(clsKeyDatesAndMetrics.clsKeyDatesAndMetricsRepalcementString.PTO_POPUP_VAL_PASTPTONONEDIT);

ScriptManager.RegisterStartupScript(wdgPTODetails, wdgPTODetails.GetType(), "Alerts", "alert('" + Message.ToString() + "')", true);

}

wdgPTODetails is my gird name. i am getting the message from database and wantted to show as alert. during debug i found that control goes to the statement but the alert message not popping up. please help.

my Design page looks like as below

<ig:webdatagrid id="wdgPTODetails" runat="server" autogeneratecolumns="False" height="350px"onrowadding="wdgPTODetails_RowAdding" onrowupdating="wdgPTODetails_RowUpdating" width="557px" ondatabound="wdgPTODetails_DataBound" DataKeyFields="PTOID">

<Columns>

<ig:BoundDataField DataFieldName="PTOID" Hidden="true" Key="PTOID"                          

DataType="System.Int32">

<Header Text="Pto_id" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="UserID" Key="UserID" DataType="System.Int32">

 <Header Text="TM Name" /></ig:BoundDataField>

<ig:BoundDataField DataFieldName="PTOStartDate" Key="PTOStartDate"                              

DataType="System.DateTime"><Header Text="Start Date" />

<Footer Text="Start Date" /></ig:BoundDataField>

<ig:BoundDataField DataFieldName="PTOEndDate" Key="PTOEndDate"                

DataType="System.DateTime">

 <Header Text="End Date" />

</ig:BoundDataField>

 <ig:BoundDataField DataFieldName="PTOStatus" Key="PTOStatus">

<Header Text="Status" />

 <Footer Text="Status" />

 </ig:BoundDataField>

 </Columns>

 

behaviour section as below

<ig:EditingCore AutoCRUD="False">

<ig:CellEditing EditModeActions-EnableF2="true" EditModeActions-MouseClick="Single" EditModeActions-EnableOnKeyPress="true"

 Enabled="true">

<EditModeActions  MouseClick="Single"/>

 <ig:EditingColumnSetting ColumnKey="UserID" ReadOnly="true" ValidatorID="RequiredFieldValidator1"/>

<ig:EditingColumnSetting ColumnKey="PTOStatus" ReadOnly="True" />

<ig:EditingColumnSetting ColumnKey="PTOStartDate" EditorID="PTO_DatePicker" ValidatorID="RequiredFieldValidator1"/>

<ig:EditingColumnSetting ColumnKey="PTOEndDate" EditorID="PTO_DatePicker" ValidatorID="RequiredFieldValidator1"/>

</ColumnSettings>

</ig:CellEditing>


 

Parents
  • 17559
    posted

    Hello vasiharan,

     

    I have been looking into your code and I believe that this code snippet will work only during a full postback or if the control is inside UpdatePanel. In the case of  updating- WebDataGrid makes async call to the server in order to commit its changes therefore your alert won’t pop up as expected.

     

    However If your WebDataGrid is placed inside of UpdatePanel you can just set the EnableAjax property of the WebDataGrid to false and then show the message like this:

        void WebDataGrid1_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e)

        {

     

            String Message = "daaa";

     

            ScriptManager.RegisterStartupScript(updatePanel1, updatePanel1.GetType(), "Alerts", "alert('" + Message.ToString() + "')", true);     

      

        }

     

    Please let me know if this helps.

Reply Children