Home > Uncategorized > Making a server-side click work when Javascript is disabled

Making a server-side click work when Javascript is disabled

A client’s accessibility guidelines stipulated that a particular asp.net website was supposed to work, even when javascript was disabled. ASP.NET relies heavily on __doPostback to perform its postbacks, and thus all server-side links are disabled when JS is disabled.
 
So, I did a workaround, with a function that can modify an asp.net linkButton so that it will work – albeit in degraded mode when JS is disabled
 

public static void MakeNoJSSafe(LinkButton lb,string alternativeURL)

{

     string strJSLink = "javascript:__doPostBack(‘" + lb.ClientID + "’,”)";

     lb.Attributes.Add("onClick",strJSLink + ";this.href=’#’");

     lb.Attributes["href"] = alternativeURL;

     return;

}

 

For me, an hour of trial-and-error, for you, a minutes cut & paste.

Please credit me, if you use this script.

 

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s