In this blog I will explain how add line break through cod behind. The main heart of the code is LiteralControl("<br/>") In Aspx <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div runat="server" id="TestDiv"> </div> <asp:Button runat="server" ...
In this blog I will show the demonstration of stack and queue generics. Stack follows the last in, first out (LIFO) principle. Queue follows the first in, first out (FIFO) principle. They are used when we have to add or fetch items in particular order. Below is the code : Stack Generic using System; using System.Collections.Generic; namespace TestConsole { class TestStackGeneric { static...
In this blog I will explain how to add item to dropdownlist after databind. I am talking about the scenario where we have bind the dropdownlist with some datasource and after binding the data we want to insert an item to dropdownlist in most cases at first option. Below is the code: The heart of the code is at: myDropdownList.Items.Insert(0,new ListItem("-- Please Select --","0")); In As...
In this blog I will explain how to match exact word in a string. I have used regular expression to match the exact word. Below is the code: Regex.IsMatch(testString, string.Format(@"\b{0}\b", wordToBeMatch)) I will explain it with two examples. Example 1 using System; using System.Text.RegularExpressions; namespace TestConsole { class SearchExactWord { static void Main(string[] args) { s...
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 In this blog I will explain how to merge two arrays together. Suppose I have one array with n items and other array with m items so our goal is to merge these two arrays in a common array but this common array should have unique records after merging of these two arrays. I have used jquery merge method to implement...
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 In this blog I will explain how to sort a list .Below a custom comparer is used NameComparer , which implements IComparer interface.In below example I am explaining with list which contains collection of strings.Here is the code: using System; using System.Collections.Generic; /// <summary> /// /// </summa...
In this blog I will explain how to get all namespaces of an assembly. I have used linq to get that work. I will explain a example for getting all namespaces of mscorlib assembly. using System; using System.Linq; using System.Reflection; public class Program { static void Main(string[] args) { //GET ASSEMBLY var assembly = Assembly.GetAssembly(typeof(string)); //GET NAMESPACES var namespa...
In this blog I will discuss the zindex issue with swf object. While using swf object in javascript there are situations when the flash object comes on the top of other controls for example dropdownlist ,textboxes etc. So to avoid this I have added one more attribute to swf object sObject .addParam ("wmode", "transparent"); Here is the code snippet: <html xmlns="http://www.w3.org/1999/...
In this blog I will explain how to hide and show div on click of checkbox with jQuery. To explain it I have used one checkbox and a div tag. If the checkbox is checked then the div is made visible and if the checkbox is unchecked the div tags is made hidden. Below is the code snippet: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title>...
In this blog I will explain how to slide down and slide up a div with jQuery. To explain it I have used one two buttons and a div tag. On click of first button the div gets slide down and on click of second button the div gets slide up. Below is the code snippet: <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1"> <title></title> <script type="text/ja...
In this blog I will explain how to get content type of a file in C# . I have wrapped the code in GetContentType method.This method will accept the file name and will return the content type of the file. Below is the code snippet: using System; public partial class _Default : System.Web.UI. Page { protected void Page_Load( object sender, EventArgs e) { string textFile= "C:\\test.txt" ; st...
In this blog I will explain how to check with regular expression (regex) if a particular sequence exists at the last of a string. Below is the code snippet: using System; using System.Text.RegularExpressions; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string pattern = "string!!$"; //First Example string inputString = "This ...
In this blog I will explain how to fade in and fadeout a div with jQuery. To explain it I have used one two buttons and a div tag. On click of first button the div gets fade in and on click of second button the div gets fade out. Below is the code snippet: <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1"> <title></title> <script type="text/javascrip...
In this blog I will explain how to get all ids of div tags in particular div ,means to get all controls id in a particular element. I have used map method of jQuery. Below is the code snippet for it: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1...
In this blog I will explain how to bind events to controls except one control with jQuery .In some requirements we have to bind a event suppose keydown to all textboxes except a particular textbox and on that particular textbox we want to have different functionality on keydown event. Below is the code snippet for it: < html xmlns ="http://www.w3.org/1999/xhtml"> < head runat ="...
In this blog I will explain how to escape single quotes with regular expression in javascript. There are issues when we have single quotes with in string in javascript. Below is the code snippet. Escaping only one single quote. < html xmlns ="http://www.w3.org/1999/xhtml"> < head id ="Head1" > < title ></ title > </ head > < body > < div > </ ...
In this blog I will show you how to rename a column name in sql. The syntax for renaming the column is EXEC SP_RENAME @objname = 'table_name.old_column_name', @newname = 'new_column_name', @objtype = 'COLUMN' According to the msdn: "sp_rename" Changes the name of a user-created object in the current database. This object can be a table, index, column, alias data type, or Microsoft .NET F...
In this blog i will explain the difference between obj.ToString() vs Convert.ToString(obj) vs (string)obj vs obj as string obj.ToString() .ToString() can be called from any object. It returns a string that represents the current Object. ToString() is a method of object, and it will always work on a non-null reference. For example: object str = "test string" ; string newTestString = str.T...
Normal 0 false false false EN-US X-NONE X-NONE In this blog I will explain how check a directory exists or not.I have used Directory class Exists method to explain it.Below is the code snippet. using System; using System.IO; namespace ConsoleApplication1 { class Program { static void Main( string [] args) { bool folderExists = Directory .Exists( @"c:\windows" ); } } } Above i have passed...
Normal 0 false false false EN-US X-NONE X-NONE In this blog I will explain how to hide mouse cursor with jQuery. I am explaining with an example where we have to hide mouse cursor when mouse is over a particular div below is the code snippet to explain it. < html xmlns ="http://www.w3.org/1999/xhtml"> < head > < title ></ title > < script type ="text/javascript...
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 In this blog I will explain how to convert scientific number to floating point number. I have used one of the overloaded method of Double.Parse. Below is the code snippet: using System; using System.Globalization; namespace ConsoleApplication1 { class Program { static void Main( string [] args) { double number= Dou...
Normal 0 false false false EN-US X-NONE X-NONE In this blog I will explain how to make a input field readonly with jQuery.Below is the code snippet: < html xmlns ="http://www.w3.org/1999/xhtml"> < head > < title ></ title > < script type ="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></ script > </ head >...
Normal 0 false false false EN-US X-NONE X-NONE In this blog I will explain how check a website folder exists or not.I have used Directory class Exists method to explain it.Below is the code snippet. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO ; public partial class How_to_chek_a...
Normal 0 false false false EN-US X-NONE X-NONE In this blog I will explain how to Refresh a Page using jQuery.I have used location.reload() for that .Below is the code snippet: < html xmlns ="http://www.w3.org/1999/xhtml"> < head > < title ></ title > < script type ="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"><...
Normal 0 false false false EN-US X-NONE X-NONE In this blog I will explain how to make image slide show using jQuery. < html xmlns ="http://www.w3.org/1999/xhtml"> < head > < title ></ title > < script type ="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></ script > </ head > < body > < img id ="...
It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.
enter your email address:
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18