Make Control Read only

Posted by Lakhangarg under ASP.NET category on | Views : 2564
Function to Make the Controls readonly.
Pass the Control id as string array and this method will generate script to set the control read only at run time.

public static string MakeControlReadOnly(params string[] ControlIds)
System.Text.StringBuilder sb = new StringBuilder(400);
sb.Append("<script language='javascript'>\n");
for (int i = 0; i < ControlIds.Length; i++)
sb.Append("document.getElementById('" + ControlIds[i] + "').readOnly=true;");
return sb.ToString();

Thanks & Regards
Lakhan Pal Garg

Comments or Responses

Login to post response