Loading ...

TrustedBlogs

Who is online?  0 guests and 0 members
home  »  blogs  »  Raghav Khunger

Communifire Blogs

Raghav Khunger : Most Recent postings

Raghav Khunger

jQuery Tools Tabs: Tab index lost on postback

yesterday by Raghav Khunger · 0 · 39

A person on the forums was struggling with jQuery tools tabs index issue on postback. On clicking the tabs and doing some postback the selected tab index was getting lost. Below is the solution on how to retaing the previous selected index which was there before postback. Complete Source: <%@ Page Language="C#" %> <script type="text/javascript"> </script> <%@ Import ...

Raghav Khunger

jQuery Tools Tabs: Set initial selected index by default

yesterday by Raghav Khunger · 0 · 22

I was working with jQuery tools tabs today and I had to set the initial index of tab selected by default. The solution is to set initialindex property in the options. Source: $("ul.tabs").tabs("div.panes > div", { initialIndex: 1 }) ; Complete code to test above: <html> <head> <title>jQuery Tools standalone demo</title> <script src="http://cdn.jquerytools.or...

Raghav Khunger

ASP.NET: Get formauthentication cookie and get the data present in it

3 days ago by Raghav Khunger · 1 · 65

A person asked me today how to get form authentication cookie and get the data present in it. I decided to write a short blog on it. Formauthentication cookie is saved with the name which we can get via FormsAuthentication.FormsCookieName property. The key here is to get the cookie via this name and Decrypt the data present in the cookie to get the data. Below is the code: HttpCookie aut...

Raghav Khunger

ASP.NET: Form authentication timeout in web.config overriding the manual ticket timeout

13 days ago by Raghav Khunger · 0 · 173

While working with one of the sample application I noticed that form authentication timeout in web.config was overriding the manual ticket's (which we created via code) timeout. Below is the code which was written in the application: var ticket = new FormsAuthenticationTicket(1, "UserName", DateTime.Now, DateTime.Now.AddMinutes(1), true, "Password"); string ticketValue = FormsAuthenticat...

Raghav Khunger

jQuery: Set cursor position in textbox

15 days ago by Raghav Khunger · 0 · 327

In this blog I will show how to select a range of characters in textbox with jquery. In my demo I have used one textbox and one button. On click of button arange of characters in textbox will be selected. Below is the sample code: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="http://ajax.go...

Raghav Khunger

Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0...

15 days ago by Raghav Khunger · 0 · 192

Recently we moved from Newtonsoft.Json 3.5 to 4.0 version. We noticed that we were getting Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0.. while working with Twitter authentication which we were using in our application. The third party dll which we were using for Twitter authentication was demanding Newstonsoft.Json 3.5 internally. So we had two ways to solve this ei...

Raghav Khunger

Remove css class in code behind

4/10/2012 by Raghav Khunger · 0 · 286

In this blog I will show how to remove a css class from an asp.net control from codebehind. It can be done just by replacing the particular class in CSSClass property value of that control with empty string. Below is the complete code: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .bold { font-weigh...

Raghav Khunger

How to check if a querystring key is present via javascript

4/10/2012 by Raghav Khunger · 0 · 255

Following is the JavaScript code to check whether a key is present in querystring or not: <script type="text/javascript"> var queryKeyPresent = function(key) { var url = window.location.href; if (url.indexOf('?' + key + '=') != -1) { return true; } else if (url.indexOf('&' + key + '=') != -1) { return true; } return false; }; </script> Usage: var check = queryKeyPresent('...

Raghav Khunger

SQL: List of stored procedures modified in last n Days

2/21/2012 by Raghav Khunger · 0 · 719

Below is the script to get list of stored procedures in last n days. SELECT [name] FROM sys.objects WHERE [type] = 'P' AND DATEDIFF(dd, [modify_date], GETDATE()) < 10 Above 10 is the number of days. You can change that value according to your need. Below is the output of my screen after running the above script on AdventureWorks DB:

Raghav Khunger

2008R2: AdventureWorks Sample database missing, from where to download?

2/21/2012 by Raghav Khunger · 0 · 632

One of my programmers just installed SQL Server 2008 R2 and found the sample database AdventureWorks missing. He was struggling for precise information on how to download the sample database. I would like to share the link from where you can find the AdventureWorks for SQL Server 2008 R2. Download Link AdventureWorks 2008R2 SR1 After installing the sample db, the screenshot:

Raghav Khunger

SQL: Get created and modified date of a stored procedure

2/21/2012 by Raghav Khunger · 1 · 574

Today I was working with some Stored procedures and I was in a need where I need to know the created and modified date of stored a procedure. Following is the script which I would like to share which I used to get the desired result: GO SELECT name, create_date, modify_date FROM sys.objects WHERE type = 'P' --AND name = 'sp_dts_getfolder' GO Output at my screen:

Raghav Khunger

ASP.NET: Enable Gzip compression via web config

2/15/2012 by Raghav Khunger · 0 · 1125

Gzip can lead your applications to perform faster since the sizes of the files delivered to client is reduced via gzip algorithm which leads to saving of bandwidth. In ASP.NET applications you can do it via some settings web config. Below is the code which you can put in your web config in system.webServer tag <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compre...

Raghav Khunger

CSS: Vertical align text next to image

2/15/2012 by Raghav Khunger · 0 · 735

Today I was working with an image and some text which I had to put next to it. The issue which was coming was to vertical align the text to middle of image. <div> <img style="height:50px" src="http://jsfiddle.net/img/logo.png" /> <span style="vertical-align:middle">:( Not coming in the middle.</span> </div> Here is the code which was not working http://jsfid...

Raghav Khunger

C#: Casting with ENUM

11/22/2011 by Raghav Khunger · 0 · 670

In this blog I will show how to cast an int to enum, enum to int and string to enum. Let's make a sample enum: MyEnum.cs namespace Sample.Console { public enum MyEnum { Item1 = 1, Item2 = 2, Item3 = 3, Item4 = 4, Item5 = 5, } } 1. Int to Enum int integerValue = 2; MyEnum myenum = (MyEnum)integerValue; //Output: item2 2. Enum to Int MyEnum myenum = MyEnum.Item3; int integerValue = (int)my...

Raghav Khunger

C#: How to get the end of the day

11/22/2011 by Raghav Khunger · 0 · 623

Yeterday I had a requirement where I needed to find the end of day in datetime. I decided to make extension on datetime to achieve it. Below is the sample code: DateTimeExtension.cs: #region Using Directives using System; #endregion namespace Sample.Console { public static class DateTimeExtension { public static DateTime GetEndOfDay(this DateTime datetime) { return datetime.AddDays(1).Ad...

Raghav Khunger

Visual Studio: The breakpoint will not currently be hit. no symbols have been loaded for this document

11/21/2011 by Raghav Khunger · 0 · 697

This message irritates me when I encounter this while debugging my code. I am writing the solution below by which this can be avoided. Step 1: Go to Build >> Configuration Manager and select "Debug " as the option for Active solution configuration. Step 2 : Go to your web project properties >> Build >> General Uncheck the Optimized code checkbox. Step 3: Clean and Rebui...

Raghav Khunger

ASP.NET: Checkboxlist to string list

11/20/2011 by Raghav Khunger · 0 · 888

In this blog I will show how to get selected values of checkboxlist in ASP.NET. The selected value can be get by applying foreach iterator on checkboxlist items and then we can find the selected items. I decided to make an extension to do the same. Below is the code for it: Control Extensions: using System.Collections.ObjectModel; using System.Linq; using System.Web.UI.WebControls; names...

Raghav Khunger

Adding linebreaks in multiline textbox's text

11/20/2011 by Raghav Khunger · 0 · 3042

Sometimes it is needed to add some text with linebreaks manually in textarea. It can be done by adding slash r and slash n (\r\n). Below is the sample code to do the same. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form id="form1" runat="server"> <textarea id="myTextBox" style="width:500px;height:300px"&...

Raghav Khunger

GitHub Extensions Visual Studio: Commit not showing the new files added

9/25/2011 by Raghav Khunger · 0 · 1679

While working with GitHub extensions commit command in VisualStudio, I noticed it was not showing the new files which I added to my solution. This may be some bug of GitExtensions but I was able to resolve this by using the Git's "Git - Pending Changes" command. Instead of using git commit command I went for Git- Pending Changes option. To do the same right click the solution and click G...

Raghav Khunger

Good reasons/excuses NOT to use version/source control

9/23/2011 by Raghav Khunger · 0 · 534

Version control is a tool to manage the changes to documents, programs, and other information stored as computer files. It allow us to track what changes we did, revert the changes, do modifications and much more. Many people still have excuses for not using version control, I have listed some of them which I have encountered them saying: I'm the only developer in my company, I don't nee...

Raghav Khunger

GitHub Visual Studio: Apply Shortcut Keys

9/22/2011 by Raghav Khunger · 0 · 706

I find it handy using shortcut keys for various commands instead of command buttons while using VisualStudio. Today, while working with GIT in Visual Studio, I decided to apply shortcut keys to various commands (Commit, Pull etc.). Below are the steps which I used to do so: Step 1: Go to Tools >> Options Step 2: In Enviornment select keyboard option. Step 3: In Show commands contai...

Raghav Khunger

C# Regex: Extract the text between square brackets, without returning the brackets themselves.

9/19/2011 by Raghav Khunger · 0 · 1903

In this blog I will show you how to extract the text between square brackets, without returning the brackets themselves. I will use REGEX class of in order to do so. Let's assume we have a string "Are you ready for regex [test text] magic?" and we want to extract "test text" from it ie. the text which lies in between the square brackets. Below is the sample code for it: using System.Text...

Raghav Khunger

How to detect IIS version in C#

9/19/2011 by Raghav Khunger · 0 · 709

In this blog I will show how to detect the IIS version using C#. We are going to make use of RegistryKey class which is the encapsulation for registry. Below is the sample code to detect the IIS version: using System; using Microsoft.Win32; namespace Sample { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Version version = GetI...

Raghav Khunger

ALTER TABLE DROP COLUMN xxx failed because one or more objects access this column.

8/12/2011 by Raghav Khunger · 0 · 1486

I was dropping a column today from a table and I got the following error ALTER TABLE DROP COLUMN xxx failed because one or more objects access this column. The complete message which was coming in SQL Server Query Analyzer message pane was: Msg 5074, Level 16, State 1, Line 1 The object 'DF_TestTable_RankId' is dependent on column 'RankId'. Msg 4922, Level 16, State 9, Line 1 ALTER TABLE...

Raghav Khunger

SQL: Add a column with a default value in existing table

8/12/2011 by Raghav Khunger · 0 · 991

Few minutes back I was working with a table in my DB and I wanted to add a new column with a default value to my existing table. I decided to write a quick blog on the script I used for the same. Syntax: ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE} Example: Let's create an example to do the same. We will first create...

Product Spotlight

ASP.NET Hosting Spotlight

Join CodeAsp.Net for FREE Today!

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:

 

Quick Vote

What kind of email newsletter would you prefer to receive from CodeAsp.Net?