Larry (larryv) wrote in csharp,

.Net custom control help

I want to use a SEO friendly link button on my page. Mind you i am sure that the page is really not all that accessible as the page I am linking to will still have javascript running on it - but thats besides the point. The correct way to do this would be to put the href thats generated by a link button into the onclick event and return void or false or whatever. And then have a SEO / accessibility friendly URL in the HREF. This seems to be what Google recommends and t seems to make sense to me.

I found this nifty .CS file here - Essentially it inherits a linkbutton and adds a NavigateUrl parameter to it so that I can put whatever href I want in there. Awesome. Just what I was looking for.

Trouble is I have no idea how to include it in my code. I feel ashamed for admitting my ignorance here. I can register a control at the top of the page, but I think I need to either use a .dll (like I do with things like the AjaxToolKit) and then reference the assembly name and the namespace. Or I can register an ascx control, and set the tagname and the src. How do I reference this .cs file in the aspx page the way this dude does? I feel like I am missing something so obvious.

For example:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ Register TagPrefix="uc1" TagName="videocontrol" src="~/controls/videocontrol.ascx" %>

Assume for the moment I have the file stored in ~/controls/CrawlableLinkButton.cs, and I want to refer to his control as he does:
<cs:CrawlableLinkButton runat="server" CommandName="Select" Text="Select" NavigateUrl='<%# "temp.aspx?PID=" + Eval("id").ToString() %>' />

Any help here? I am a bit thick and getting more and more tired. I know deep down I am a good .Net developer, honest - so why can I not figure out the little things?
  • Post a new comment


    default userpic