Posts Tagged ‘:’

Adding UserControl Dynamically and Set Properties in

November 8, 2010 1 comment

Adding UserControl Dynamically and Set Properties in

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

For More Details Visit :


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

Getting Started


Date.october().fourth().sunday(, endDate)'d-MMM-yyyy')
Date.getDaysInMonth(2007, 9)

RegEx to Replace multiple line breaks in

October 4, 2010 Leave a comment

Suppose the text is

“Long Description





Mulitple line breaks can be replaced with regex as follows:

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

Get Client ID using Jquery

September 20, 2010 1 comment

When we are developing client side in, we need the id of the controls, but the IDs are merged with master page naming containers.

The id will look something like this

But using Jquery we can get id like this

$("#<%= <strong>txtboxId</strong>.ClientID %>")
$("[id$=_<strong> txtboxId</strong>]").attr("id")

You can also use the function

function GetClientID(id, context) {
var el = $("#" + id, context);
if (el.length < 1)
el = $("[id$=_" + id + "]", context);
return el;



Or if I want to be specific about the container:

For More Details Visit:

Solving Calendar Extender Problem in Modal Popup Extender

September 13, 2010 3 comments

Calendar Extender control when placed inside modal popup extender will not be seen in front. To solve this issue, we have the following solution

<cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="Textbox1"
 PopupPosition="Right" runat="server" <strong>OnClientShown="CalendarShown"></strong> </cc1:CalendarExtender>
function calendarShown(sender, args)
    { = 10005;

Truncate Strings At Complete Words without chopping words half way In C#,

August 30, 2010 1 comment

There is always a common need to display n number of characters of a string and then….
But it regular practice we lose the characters displaying incomplete word.
For Eg. This is an example of long string
Now what happens when we use substring(..), the result will be
This is an example o…
It left the word “of” incomplete, chopping off the words in half way. To avoid below are the solutions to it.

public static string TruncateWithoutChopping(this string strText, int intLength)
    if (strText == null || strText.Length < intLength)
        return strText;
    int intNextSpace = strText.LastIndexOf(" ", intLength);
    return string.Format("{0}...", strText.Substring(0, (intNextSpace > 0) ? intNextSpace: strText).Trim());

Another Extension method is as follows:

public static string TruncateWithoutChopping (this string strText, int intLength)
      throw new ArgumentNullException(s);
    var words = strText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    var sbText = new StringBuilder();

    foreach (var word in words.Where(word => (sbText.ToString().Length + word.Length) <= intLength))
      sbText.Append(word + " ");
    return sbText.ToString().TrimEnd(' ') + "...";

Using Jquery Intellisense in Visual Studio

August 16, 2010 Leave a comment

1) Using Jquery Intellisense in Page

<script src=”” type=”text/javascript”&gt;

<script src=”” type=”text/javascript”&gt;

You can get the latest version from here:

2) Using Jquery Intellisense in External Javscript files

1)      Download Latest Jquery files and its related vsdoc file.

For ex:

Jquery Files:  jquery-1.3.2.js

Vsdoc File:  Jquery-1.3.2-vsdoc.js

2)   Include both files in your project directory

3)   Open your external javascript file in which you want intellisense

Drag the   Jquery-1.3.2-vsdoc.js file on the first line at top of external file.

It will be displayed as below:

/// <reference path=”jquery-1.3.2-vsdoc2.js” />

That’s it you can now use intellisense in that file. To test whether it is working or not you can type $( and you should be presented with documentation.

Note: jQuery and the documentation file need to be named the same with the exception that the documentation file end with -vsdoc.js