Adding UserControl Dynamically and Set Properties in Asp.net

November 8, 2010 1 comment

Adding UserControl Dynamically and Set Properties in Asp.net

ucMyUserControl ucUser = (ucMyUserControl )LoadControl(“~/folder/MyUserControl.ascx”);
ucUser.MyProperty = “I got my property”; 
MyDiv.Controls.Add(ucUser);

For More Details Visit : http://www.highonmicrosoft.com/dynamically-loading-and-accessing-the-properties-of-the-user-control.html http://stackoverflow.com/questions/213429/programmatically-adding-user-controls-inside-an-updatepanel http://geekswithblogs.net/samerpaul/archive/2009/11/13/dynamically-adding-web-user-controls-and-accessing-their-properties-by.aspx http://stackoverflow.com/questions/508826/set-properties-on-dynamically-added-usercontrol

Validate your Javascript for Errors, checks

November 1, 2010 Leave a comment

Below are the software that can be used to validate your javascript  code, check for errors :

JSLint

http://www.jslint.com/ 

Scryptik javascript editor and validator

http://www.purpleoar.co.nz/scryptik/ 

Yaldex  

http://www.yaldex.com/JSFactory_Pro.htm

Insert JavaScript & CSS Dynamically

October 25, 2010 Leave a comment

Below is the code for Adding Javascript:

var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'http://www.somedomain.com/somescript.js';
headID.appendChild(newScript);

Below is the code for Adding CSS:

var headID = document.getElementsByTagName("head")[0];
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = 'FireFox.css';
cssNode.media = 'screen';
headID.appendChild(cssNode);

For More Details Refer:

http://bit.ly/9Q8bDK

http://bit.ly/9Q8bDK

Using Datejs – Open Source Javascript Date Library

October 18, 2010 Leave a comment

Datejs is an open source JavaScript Date library for parsing, formatting and processing

Overview & Download

http://code.google.com/p/datejs/

Getting Started

http://www.datejs.com/2007/11/27/getting-started-with-datejs/

Documentation

http://code.google.com/p/datejs/wiki/APIDocumentation

Examples:


Date.today()
Date.today().next().friday()
Date.today().is().november()
Date.today().addDays(1)
Date.today().addMonths(-3)
Date.october().fourth().sunday(
Date.today().between(startDate, endDate)  
Date.today().toString('d-MMM-yyyy')
Date.today().toShortDateString()
Date.getDayNumberFromName('sat')
Date.isLeapYear(2008)
Date.getDaysInMonth(2007, 9)

RegEx to Replace multiple line breaks in Asp.net

October 4, 2010 Leave a comment

Suppose the text is

“Long Description

With

Multiple

Line

Breaks”

Mulitple line breaks can be replaced with regex as follows:

Regex.Replace(yourlongtext, "[\r\n]+", " - - ");