Friday, September 4, 2009

Telerik RadToolBar

RadToolBar has Items,If the Items are RadtoolBarButton and if the user clicks on the button it has to goto the URL which you have already specified

You can try like this

<telerik:radtoolbar id="radToolBarID" runat="server" cssclass="toolbar">
<items>
<telerik:radtoolbarbutton navigateurl="~/default.aspx" postback="false" text="Goto Default Page" causesvalidation="false">
<telerik:radtoolbarbutton navigateurl="~/HomePage.aspx" postback="false" text="Goto Home Page" causesvalidation="false">
</items>
</telerik:radtoolbar>


If you want to use the INLINE code in NavigateURl from codebehind file..it wont work ..see this example for asp:Hyperlink


<asp:HyperLink runat="server" ID="hmURL" NavigateUrl='<%#this.homePageURL%>' Text="Home"></asp:HyperLink>

In codebehind.cs

protected void Page_Load(object sender, EventArgs e)
{

homePageURL = "~/projectFolder/homePage.aspx";
}

<%#this.homePageURL%> this is the inline code used to get the value from the codebehind but samething cant be used in Telerik RadToolBar's radtoolbarbutton->NavigateURL
So we have to use it in the codebehind like this and in the aspx file remove the navigateURL


<telerik:radtoolbar id="radToolBarID" runat="server" cssclass="toolbar">
<items>
<telerik:radtoolbarbutton navigateurl="~/default.aspx" postback="false" text="Goto Default Page" causesvalidation="false">
<telerik:radtoolbarbutton postback="false" text="Goto Home Page" causesvalidation="false">
</telerik:radtoolbarbutton>
</telerik:radtoolbarbutton>

codeBehind.cs

public string homePageURL;
protected void Page_Load(object sender, EventArgs e)
{
homePageURL = "~/projectFolder/homePage.aspx";
Telerik.Web.UI.RadToolBarButton radToolBarBtn = (Telerik.Web.UI.RadToolBarButton)radToolBarID.FindItemByText("Goto Home Page");
radToolBarBtn.NavigateUrl = homePageURL;
}

1 comment:

  1. THanks for this - solved a problem of dynamically updating URL Navigate links.

    ReplyDelete