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 ...
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...
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...
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...
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...
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...
PRODUCT SPOTLIGHT This is an addition to my series of blog posts on jQuery Mobile: jQuery Mobile Introduction & Tips To Get Started jQuery Mobile Getting Started So, if you've been following my posts so far, you should have a good overview of jQuery Mobile, it's documentation, how to set up your Visual Studio environment, and the structure of a jQuery Mobile page. Today, I'm going to...
add message icon with count displayed on it as new messages come into my gridview. i want to do this in asp.net for web application.
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...
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('...
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:
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:
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:
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...
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...
Hi, Websoftcreation started new batch of asp.net and PHP for MCA,M.Sc,B.tech from 16 Jan,2012 at Jaipur centre. You can take part in this training by just post request on websoftcreation.co.in website. Regards Websoftcreation,Jaipur
Well this is really not my last post but I will not be blogging anymore here to avoid cross posting of contents. Instead you can visit my official blog at: Vinz' Blog Note: Stop blogging here doesn't mean I will stop contributing to the codeasp community, of course I will still be moderating posts and participating in the forums and try my best to answer to questions to the best that I c...
We were stuck with a weird issue. Our ASP.NET web app was crashing for some reason and the event log only displayed Stackoverflow exception. We want to narrow down the reason for the crash and since stackoverflow exceptions are easy to debug (even crash dumps didnt give help much), we wanted our app to shut down the moment first time this excepton occured. Application pool recycles itsel...
The default SqlCommand timeout is 30 seconds, so you might get this error while executing a lengthy Sql operation (like creating a DB and its schema via C# code): Error : Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. In order to fix this, just increase the command time out as follows: myCommand.CommandTimeout = 120; // 2...
We had created a Visual Studio project in C# to create SQL Server 2005 database via C# code. We were referencing these assemblies: Microsoft.SqlServer.Management.Sdk.Sfc.dll Microsoft.SqlServer.Smo.dll Microsoft.SqlServer.ConnectionInfo.dll We also added this DLL but did not reference it as we realized it was required internally by the above assemblies: Microsoft.SqlServer.SqlClrProvider...
This year again, Macedonian .NET User Group is organizing the biggest event in balkans... CODE CAMP 2011 Event will be held at 26th of November at FON University, Skopje, Macedonia. There are 24 speakers, 7 MVPs, 25 sessions and 5 tracks. In the first 15 hours we got 600 registered attendees... and we expect this number to reach 1000 by the end of registrations. I will be speaking on top...
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...
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...
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...
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...
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