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

NavigateUrl

4 Answers 252 Views
Button
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Veteran
sitefinitysteve asked on 12 Jun 2011, 10:43 PM
Is there any way to have the button look like the cool skinned buttons while giving me NavigateUrl?...instead of the button falling back to the LinkButton look when NavURL is used?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 13 Jun 2011, 10:57 AM
Hello Steve,

As far as I know there is no easy way to make both link buttons and standard buttons to appear the same way having the standard button look and feel. They have different rendering depending on their front-end requirements. One suggestion is to create custom skin for the RadButton.

Please go through the following tutorial for more on creating custom skin.
Creating a Custom Skin for RadButton

Thanks,
Shinu.
0
Slav
Telerik team
answered on 13 Jun 2011, 12:53 PM
Hi Steve,

If you handle the client-side event OnClientClicking you can keep the button look without having to change the ButtonType property to LinkButton. In the event handler you must open with Javascript the URL, specified in the NavigateUrl property and after that you should cancel the event and postback.

Below is a sample, showing how to achieve this:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ButtonRedirect.aspx.cs" Inherits="ButtonRedirect" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
 
        <script type="text/javascript">
            function OnClientClicking(button, args) {
                window.location = button.get_navigateUrl();
                args.set_cancel(true);
            }
        </script>
 
        <telerik:RadButton ID="RadButton" runat="server" Text="RadButton" NavigateUrl="http://www.telerik.com/" OnClientClicking="OnClientClicking">
        </telerik:RadButton>
    </div>
    </form>
</body>
</html>


Regards,
Slav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Tom
Top achievements
Rank 1
answered on 18 Jul 2014, 03:40 PM
Thanks for the code--this is super helpful.
0
kengsheng
Top achievements
Rank 1
answered on 12 Sep 2014, 02:59 AM
This is super helpful and simple! Thank you very much! =D
Tags
Button
Asked by
sitefinitysteve
Top achievements
Rank 2
Veteran
Answers by
Shinu
Top achievements
Rank 1
Slav
Telerik team
Tom
Top achievements
Rank 1
kengsheng
Top achievements
Rank 1
Share this question
or