Execute Javascript code on a navigation button in Wizard Control.

As you may know the wizard control, provided by ASP.NET 2.0, allows us to create a navigation system with multiple steps. if you are not familiar with the wizard control please check below link

Wizard Control in ASP.NET 2.0

Once you create a wizard step, you can set the StepType to dynamically create the proper navigation buttons. For this example, just select Start.

To execute a javascript function for the "Next" button, you have to find the control inside that wizard and then  handle the proper event to call that method.

First, right click on the wizard control, in design mode and select "Convert to start nagivation template". Now if you look into the HTML code you will find that visual studio 2005 dynamically added the below

<StartNavigationTemplate>

<asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" Text="Next" />

</StartNavigationTemplate>


Now the Next button has an id "StartNextButton" and you can in your code behind use the below code to get this button at runtime and add the javascript code

            Button nextButton = (Button)Wizard1.FindControl("StartNavigationTemplateContainerID").FindControl("StartNextButton");
            nextButton.Attributes.Add("onclick","alert('This is the client click event');");

Hope this helps,

Published 27 August 2007 10:39 AM by haissam

Comments

# Grace said on 15 January, 2008 12:02 PM

Thanks for sharing your codes! This is exactly what I'm looking for.  And this has saved me a lot of time and headache for research!  :)

# TipsOnLips.net said on 07 April, 2009 01:03 AM

ASP.NET Controls Articles

# TipsOnLips.net said on 07 April, 2009 04:28 AM

ASP.NET Controls Articles

# Jack said on 03 September, 2009 09:04 PM

you can use OnClientClick in html for short

This site

Search

Go

This Blog

Syndication

Sponsors

  • MaximumASP
  • Social Bookmarking
    Online Shopping
    asp.net hosting
    UK online local dating