This is an existing VS2002 project using ComponentArt menu for page navigation. Currently menu items are attached to the client side event for page
validation. Upon the page submit, the control is directed to client side script for page validation. On successful page validation, the control is passed
onto server side script for saving the data.
This control is not supported in VS2012 enviornment, so we are in process of upgrading the control with RadMenu control.
Currently the ComponentArt menu control is placed inside Header page(user control) and this page is inherited in all other pages using base page concept
to render the menu.
We are having issue using RadMenu control in the same fashion.
The issue is when we associated custom client side script to RadMenu item, the control is going to custom Client side script as intended for the validation,
but after the validation it is going back to RadMenu built-in client side event (OnClientItemClicked) again for client side click rather than passing the
clontrol to RadMenu Server side click event OnItemClick="RadMenu1_ItemClick.
Issue is, if the custom client side validation fails, we want to stop there itself rather going back to built-in client side for further validation.
Is it possible to stop the control going to radMenu built-in validation, if the custom client side validation fails ?
3 Answers, 1 is accepted
I am glad to hear that you decided to use our RadMenu control in your application.
As far as I understand you are trying to stop firing the the RadMenu client-side event ClientItemClicked and the server-side event ItemClick. An easy and convenient way of achieving such scenario would be to use the RadMenu ClientItemClicking event handler for implementing your custom client validation. If it fails you can simply cancel any further execution so the client-side click and server-side click events will not be fired. I have attached a sample web site project that contains the RadMenu in user control and a page that includes this user control. The console log messages shows in what sequence the events are processed. In order to review the log you can open the console tab of your browser's developer tools.
If this is not exact functionality you want to achieve, please explain which events you want to prevent if your custom client-side validation fails. A sample scenario that illustrates your case will be very helpful.
Please refer to our RadMenu client-side programming section and specifically to our RadMenu client-side events help article for more information.
Assume I have Page1.aspx,Page2.aspx,Page3.aspx,
I created a a user control ie. Header Page (System.Web.UI.UserControl) , where I put a radMenu.
I added this user control (Header Page) in Page1,Page2 and Page3.
In the page Load of the UserControl ,I am adding MenuItems as follows.
Note :clsNavigationState object value will be assigned from Page1,Page2,Page3 etc..
objMenuItem.Attributes.Add("onclick", "return " + objMenuButton.AttributesValue + "")
Assume Page1 has 10 TextBoxes , Page2 has 5 Dropdowns and Page3 has 12 TextBoxes .
***Scenario 1 - I have Submit and Clear Buttons***
When I click ClearButton On Page1 , it should clear 10 TextBoxes in Page1 and stop the execution there.
***Scenario 2 - I have Submit and Clear Buttons***
When I Click Submit Button On Page1 , it should validate 10 TextBoxes in Page1 .if validation fails stop the execution there
else continue and PostBack the Page
QUESTION IS How do I notify the ClientItemClicking event to Proceed or Not from the above Scenario.
Please find attached a sample project that contains a user control "HeaderUserControlVB" and two aspx pages. In both pages the user control is included. The main difference comes in the code behind:
- In the page load event handler you can find the RadMenu control using the user control as shown in the attached sample. Then you can create different items for the specific page using your method "addMenuItemRad". I would suggest attaching the RadMenu OnClientItemClicking client-side event handler from the code behind and create a function with the same name in the markup code. This way you can implement a custom logic to be executed when a menu item is clicked based on the current page- if this is Page1.aspx you will clear the text boxes and if this is Page2.aspx you can clear the drop down lists. In the comments you can find out how you can get the clicked menu item clicked item and perform different logic based on the fact which menu item is clicked - for example the clear or the new button.