set css class for controls using javascript from code behind
June 10, 2009string scriptString = "document.getElementById('ctl00_tvMainNavigationn17')";
scriptString += ".setAttribute('className', 'NodeBold');";
scriptString += "document.getElementById('ctl00_tvMainNavigationn18').setAttribute('className', 'NodeBoldClass');";
scriptString += "document.getElementById('ctl00_tvMainNavigationn19').setAttribute('className', 'NodeBoldClass');";
Page.RegisterStartupScript("onload", scriptString);
Call a master page Method() from content page using c#
May 26, 2009In the Master page code behind file define the method you want to call as Public.
public partial class MasterPage : System.Web.UI.MasterPage
{
public void ShowLicenseErrorImage()
{
this.IMG_LicenseExceedWarn.Visible =
this.lblLicenseMisuse.Visible =
this.lblDetails.Visible = true;
}
public void HideLicenseErrorImage()
{
this.IMG_LicenseExceedWarn.Visible =
this.lblLicenseMisuse.Visible =
this.lblDetails.Visible = false;
}
}
Now in the content page code befind type the following.
MasterPage master = (MasterPage)this.Master;
master.ShowLicenseErrorImage();
Where “MasterPage” is the class name of class in master page.
Thats it!!!
Set culture to your application according to the client’s browser language
April 2, 2009As a part of globalization of an application we will require to set culture depending on the which language client’s browser is using. And using these culture we should represent date, numbers, currency etc in specific format. For this we can use Request.UserLanguages. Following is a method which returns the code of language which the browser is using. Read the rest of this entry »
Javascript: email address field validation
January 22, 2009Use the following code
Read the rest of this entry »
Javascript: Numerical Only
January 22, 2009Use this javascript function to check whether the textbox value is numerical or not
function NumericalOnly() {
var numericalOnly = new RegExp(“^[0-9]*$”)
var textbox = document.getElementById(“TextBox1″).value;
if (!numericalOnly.test(textbox)) {
alert(“Please enter a valid number!”)
}
}
Thanks,
Anil.
Javascript: Validate Date
January 22, 2009Put this code in the script tag under head tag.
Read the rest of this entry »
Wallpaper Changer
January 14, 2009You can use the following code to change the desktop wallpaper programmatically. If you want the whole project, then you can download it from this link-
Read the rest of this entry »
Posted by akbbhatt
Posted by akbbhatt
Posted by akbbhatt