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

RadNumericTextBox fires window.onbeforeunload event

5 Answers 128 Views
Input
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 17 Aug 2009, 04:00 PM
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?

5 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 18 Aug 2009, 05:08 PM
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.
0
John
Top achievements
Rank 1
answered on 18 Aug 2009, 06:34 PM
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!
0
Schlurk
Top achievements
Rank 2
answered on 18 Aug 2009, 07:41 PM
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.
0
siva
Top achievements
Rank 1
answered on 27 Dec 2010, 11:32 AM
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

 

0
siva
Top achievements
Rank 1
answered on 10 Jan 2011, 11:41 AM

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

 

Tags
Input
Asked by
John
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
John
Top achievements
Rank 1
siva
Top achievements
Rank 1
Share this question
or