Wednesday, March 17, 2004 - Posts

Javascript in ASP.NET

Yeah yet another problem over.
I was bizzy getting JavaScript working on a Web Control and I couldn’t find I a way to fix it so I went reading a the following article “Taking Full Control: Build Your Own Reusable Datalist with VS.NET” and I found this:
this.Attributes.Add("OnClick", string.Format("return confirm('{0}')",this.Confirmation));

With a bit of editing got the following stuff for one of my hyperlinks:
this.HyperLink1.Attributes.Add("OnClick","window.open(\"BrandAdd\");");
this.HyperLink1.Attributes.Add("onmouseover","document.getElementById(\"HyperLink1\").style.color=\"#008000\"");
this.HyperLink1.Attributes.Add("onmouseout","document.getElementById(\"HyperLink1\").style.color=\"#000000\"");
so now if you go over the hyperlink it will be green and if you go of off it it will turn black also if you click on it it will open a new window.

It is great and it work weee :P :)