RadNumericTextBox fires window.onbeforeunload event

6 posts, 0 answers
  1. John
    John avatar
    16 posts
    Member since:
    Jun 2009

    Posted 17 Aug 2009 Link to this post

    Hello,
    I have a RadNumeric textbox with the spinbuttons enabled.  When I change the value of the RadNumericTextBox using the spin buttons, the

    window.onbeforeunload event fires.  Is there a way to prevent this from happening?

  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 18 Aug 2009 Link to this post

    The window.onbeforeunload event should only be fired when the browser windows is closing so this seems strange. Does this happen for any Ajax event or is it purely singling out the RadNumericTextBox? Also, posting some code might do good since it might be something outside of  the control that is causing it.
  3. John
    John avatar
    16 posts
    Member since:
    Jun 2009

    Posted 18 Aug 2009 Link to this post

    Thank you for the reply.  To answer your question, it only happens with the spin buttons on NumericTextBoxes and when I click on LinkButtons.  I was able to handle the LinkButton issue using the method I show below, but this doesn't work for the NumericTextBox.

    This is the reply I got from a Telerik Support Ticket:
    Unfortunately the described behavior is expected, because the document.unload is raised because of the desire to change the value of the input control.

    If you have any ideas, I would greatly appreciate it.  Here is my javascript:
    var needToConfirm = true;     
    window.onbeforeunload = confirmExit;     
    function confirmExit() {     
    4     if (needToConfirm) {     
    5         return "You will lose all unsaved data.";     
    6     }     
    7 }     
    function disableConfirmExit() {     
    9     needToConfirm = false;     
    10 }    
     

    And here is my control:
    <telerik:RadNumericTextBox ID="LocationCountRadNumericTextBox" runat="server" ShowSpinButtons="true"    
    2       MinValue="1" MaxValue="30" Type="Number" MaxLength="2" Value="1" Width="40px"    
    3       OnTextChanged="LocationCountRadNumericTextBox_TextChanged" AutoPostBack="true">     
    4       <IncrementSettings InterceptArrowKeys="true" InterceptMouseWheel="true" />    
    5       <NumberFormat DecimalDigits="0" GroupSeparator="" AllowRounding="true"    
    6              KeepNotRoundedValue="false" />    
    7       <ClientEvents OnKeyPress="RadNumericTextBoxKeyPress" OnButtonClick="disableConfirmExit" />    
    </telerik:RadNumericTextBox>    
     

    This seems to work, but inconsistently.  The OnButtonClick client event calls the disableConfirmExit JavaScript function to set the needToConfirm value to false, and the OnTextChanged server event re-sets the needToConfirm value back to true.  This method works with my LinkButtons and Button controls, but after clicking the spin buttons a few times the prompt is displayed.  There isn't a pattern as to when it's displayed, either.

    After posing this to the Telerik Support Person, here was their response:
    I  was able to reproduce the described behavior on IE browser. I could not replicate this issue in FF. I suppose that the cause of this abnormality is the speed of the implementation of JavaScript code, which is slower in IE. Unfortunately my abilities to help you further with this problem are depleted.

    Thanks for any advice you might provide!
  4. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 18 Aug 2009 Link to this post

    Did you try to test it in FF, Chrome, and/or Opera to see if it does behave differently in other browsers? That could be a check you might want to do since that could further confirm the fact that it has to do with the javascript engine of the browser in use. If you attempt to use other controls between spins does that change anything? If you refresh/reload the page does it "reset" the behavior? There might be a limit where under your script works fine and above it can fire off correctly or fail which you could use as a maximum # of spin per page load or something in that fashion.
  5. siva
    siva avatar
    10 posts
    Member since:
    Oct 2010

    Posted 27 Dec 2010 Link to this post

    HI,

    am using following grid

     

    <table id="tblUpper" width="100%" cellpadding="0" cellspacing="0" style="table-layout: fixed;">

     

     

    <tr>

     

     

    <td valign="top">

     


     

    <telerik:RadGrid ID="RadGridClientMandate" GridLines="None" runat="server" AutoGenerateColumns="False"

     

     

    Skin="3iGrid" EnableEmbeddedSkins="false" Height="390px" Width="99.5%">

     

     

    <MasterTableView InsertItemDisplay="Bottom" Width="100%" DataKeyNames="Security"

     

     

    Visible="true">

     

     

    <RowIndicatorColumn>

     

     

    <HeaderStyle Width="20px" />

     

     

    </RowIndicatorColumn>

     

     

    <ExpandCollapseColumn>

     

     

    <HeaderStyle Width="20px" />

     

     

    </ExpandCollapseColumn>

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn HeaderText="Asset Type" UniqueName="Asset_type" Visible="true">

     

     

    <ItemTemplate>

     

     

    <asp:Label ID="Asset_type" runat="server" Text='<%# Bind("Asset_type") %>' />

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

    <

     

    telerik:GridTemplateColumn HeaderText="Mandate Qty" UniqueName="Mandate Qty">

     

     

    <ItemTemplate>
    <telerik:RadNumericTextBox ID="MandateQty" runat="server" CssClass="input" Skin="Office2007" ReadOnly="True" EnabledStyle-BackColor="White"

     

     

    MaxLength="18" DbValue='<%# Bind("MandateQty") %>' OnTextChanged="MandateQty_OnTextChanged" NumberFormat-GroupSeparator=","

     

     

    Width="80px" >

     

     

    <NumberFormat AllowRounding="True" KeepNotRoundedValue="False" />

     

     

    <DisabledStyle HorizontalAlign="Right"/>

     

     

    <EmptyMessageStyle HorizontalAlign="Right" />

     

     

    <FocusedStyle HorizontalAlign="Right" />

     

     

    <HoveredStyle HorizontalAlign="Right" />

     

     

    <NegativeStyle HorizontalAlign="Right" />

     

     

    <ReadOnlyStyle HorizontalAlign="Right" />

     

     

    <EnabledStyle HorizontalAlign="Right" />

     

     

    <InvalidStyle HorizontalAlign="Right" />

     

     

    <NumberFormat DecimalDigits = "2" />

     

     

    </telerik:RadNumericTextBox>

     

     

    </ItemTemplate>

     


    </

     

    Columns>

     

     

    </MasterTableView>

     

     

    <ClientSettings>

     

     

    <Scrolling AllowScroll="True" />

     

     

    <Resizing AllowColumnResize="True" />

     

     

    </ClientSettings>

     

     

    </telerik:RadGrid>

     

     

    </td>

     

     

    </tr>

     

     

    </table>

    i have used radnumerictextbox with OnTextChange event , but event is not get fired plz help me

     

  6. siva
    siva avatar
    10 posts
    Member since:
    Oct 2010

    Posted 10 Jan 2011 Link to this post

    Hi princy,
    Thnaks for your code it works!!!
    now i hav another doubt
    am using follwing type of grid....

    <
    table id="tblUpper" width="100%" cellpadding="0" cellspacing="0" style="table-layout: fixed;">
    <tr><td valign="top">
    <telerik:RadGrid ID="RadGridClientMandate" GridLines="None" runat="server" AutoGenerateColumns="False"
    OnItemDataBound="drmandates_ItemDataBound" Skin="3iGrid" EnableEmbeddedSkins="false"

     

     

    Height="390px" Width="99.5%">

     

     

    <MasterTableView InsertItemDisplay="Bottom" Width="100%" DataKeyNames="Security"Visible="true">
    <RowIndicatorColumn>

     

     

    <HeaderStyle Width="20px" />

     

     

    </RowIndicatorColumn><ExpandCollapseColumn>

     

     

    <HeaderStyle Width="20px" />

     

     

    </ExpandCollapseColumn><Columns>
    <telerik:GridTemplateColumn HeaderText="Asset Type" UniqueName="Asset_type" Visible="true">
    <ItemTemplate>
    <asp:Label ID="Asset_type" runat="server" Text='<%# Bind("Asset_type") %>' />
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn HeaderText="Security" UniqueName="Security" Visible="true">
    <ItemTemplate>
    <asp:Label ID="Security" runat="server" Text='<%# Bind("Security") %>' />
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn HeaderText="Price" ItemStyle-HorizontalAlign="Right" UniqueName="Price">
    <ItemTemplate>
    <telerik:RadNumericTextBox ID="Price" runat="server" CssClass="input" Skin="Office2007"
    ReadOnly="false" EnabledStyle-BackColor="White" MaxLength="18" DbValue='<%# Bind("Price") %>'
    EnableEmbeddedSkins ="false" NumberFormat-GroupSeparator="," Width="80px"
    AutoPostBack="true">
    <NumberFormat AllowRounding="True" KeepNotRoundedValue="False" />
    <DisabledStyle HorizontalAlign= "Right" />
    <EmptyMessageStyle HorizontalAlign="Right" />
    <FocusedStyle HorizontalAlign="Right" />
    <HoveredStyle HorizontalAlign="Right" />
    <NegativeStyle HorizontalAlign="Right" />
    <ReadOnlyStyle HorizontalAlign="Right" />
    <EnabledStyle HorizontalAlign="Right" />
    <InvalidStyle HorizontalAlign="Right" />
    <NumberFormat DecimalDigits="2" />
    </telerik:RadNumericTextBox>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    </Columns>
    </MasterTableView>
    <ClientSettings>
    <Scrolling AllowScroll="True" />
    <Resizing AllowColumnResize="True" />
    </ClientSettings>
    </telerik:RadGrid>
    </td></tr></table>

    am using ranumerictextbox for editable column,
    now i need to use radnumerictextbox as label column in my grid, it shud no visible as editable r textbox, it shud be as such as normal labe field

    and i hav grid with alternate color for alternate rows ,so my radnumerictextbox shud be viewed with grid bgcolor
    plz help me

     

Back to Top