Hi,
We have two Radgrids on a web content page. For one grid, the edit form is an aspx page. When you click edit in the grid, an aspx page is loaded into the edit section of the grid. We created an eventhandler for onbeforeunload event for the aspx page, so when user leaves the aspx page(have the edit section open) and click on a button, linkbutton, leave the content page...etc, a popup will display. This works great except clicking the Add New Record in the other grid displays our pop up and clicking the +sign(left to Add New Record) doesn't, which confuses our users. Refresh button and its sign have the same issue.
Could any body help me?
Thanks & Regards,
Zwu
5 Answers, 1 is accepted
I am afraid that I can not draw a clear picture of your scenario. Could you provide some code snippets that demonstrate the case you have. The best option would be to open a formal support ticket and send us a small sample runnable project that we could debug locally. This way we would be able to provide you more to the point resolution.
Regards,
Martin
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.
Hi Martin,
Thanks for the information.
Telerik created a support ticket for us and I have already created/posted my sample application. So the issue is being taken care of.
Thanks,
Ziying
I have the same issue with the window.onbeforeunload function in Javascript.
It also triggers the popup when I click on Insert, Update and Cancel.
May I have a snippet or a way to solve this please?
I checked this solution at the bottom of the following link: http://www.telerik.com/community/forums/aspnet/grid/window-onbeforeunload-is-triggered.aspx but it unfortunately doesn't work.
I succeeded in accessing to the right linkbuttons using this kind of procedure on the ItemCreated Event but the modifications of the linkbuttons doesn't seem to work:
void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
foreach (Control c1 in e.Item.Controls[0].Controls) |
{ |
foreach (Control c2 in c1.Controls) |
{ |
foreach (Control c3 in c2.Controls) |
{ |
foreach (Control c4 in c3.Controls) |
{ |
if (c4 is LinkButton) |
{ |
LinkButton l = c4 as LinkButton; |
l.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(l, string.Empty); |
} |
} |
} |
} |
} |
} |
Thanks for your reply
Remi
Thanks for the code snippet. I didn't try to access the link button but I will sometime.
Our problem is that the plus sign + doesn't call onbeforeunload and AddNewRecord does, which confuses our users.
1: I give the plus sign a new image and it fires onbeforeunload event. so both fires the event now.
2:you can use the below snippet to access + and AddNewRecord... what i did is to make one of them invisible so that our users
won't be confused---shouldn't they have the same behaviour?
Thanks,
Ziying
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
Button addButton = e.Item.FindControl("AddNewRecordButton") as Button;
if (addButton != null)
addButton.Visible = false;
LinkButton lnkButton = (LinkButton)e.Item.FindControl("InitInsertButton");
if (lnkButton != null)
lnkButton.Visible = false;
........
}
I finally understand your problem, because I'm facing it too!
As I saw on the following link http://www.telerik.com/community/forums/aspnet/grid/window-onbeforeunload-is-triggered.aspx
"Onbeforeunload will be triggered on every A element with href="javascript:SomeFunction();". By default ASP.NET LinkButtons are rendered as <a href="javascript:__doPostBack();" ."
That's why there is this problem on the "Add a new row" and "Refresh" text. However, the + sign (which is an imagebutton) works perfectly.
I used the following snippet to remove all link buttons.
void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
foreach (Control c1 in e.Item.Controls[0].Controls) |
{ |
foreach (Control c2 in c1.Controls) |
{ |
foreach (Control c3 in c2.Controls) |
{ |
foreach (Control c4 in c3.Controls) |
{ |
if (c4 is LinkButton) |
{ |
c4.Visible = false; |
} |
} |
} |
} |
} |
} |
Any better solution than masking LinkButtons would be appreciated...
-------------------
For my issues with the Insert, Update and Cancel texts, I just had to set the EditColumn-ButtonType to "ImageButton" instead of "LinkButtons".
<EditFormSettings EditFormType="AutoGenerated" EditColumn-ButtonType="ImageButton"> |
</EditFormSettings> |
Hope my solution fits with somebody problems.
Remi