RSSAll Entries in the "ASP.NET" Category

Retrieving domain information through ASP.NET

Retrieving domain information through ASP.NET

There are many  domain checking websites available that gives all the information regarding domains. WhoIs is one of them. Following is a sample asp.net code that connects to one of WhoIs servers and retrieve information of a specific website.
using System; using System.Collections.Generic; using System.Linq; [...]

Add meta data dynamically

Add meta data dynamically

Add meta-data dynamically to your page by adding a HtmlMeta control to your Header. In this example I dynamically add a keyword string to the page.
string keyWords = “metatags, html, dynamic, generate”;
HtmlMeta keywords = new HtmlMeta();
keywords.Name = “keywords”;
keywords.Content = keyWords;
Page.Header.Controls.Add(keywords);

Date Time string formatting in ASP.NET

Date Time string formatting in ASP.NET

With the following code you can format a DateTime within a Databind.
<%# DateTime.Parse(Eval("DateModified").ToString()).ToString("MM-dd-yyyy")%>

Some more format specifiers that can change format of datetime objects the way it is required.

Format specifier
Name

d
Short date pattern

D
Long date pattern

t
Short time pattern

T
Long time pattern

f
Full date/time pattern ( short time )

F
Full date/time pattern ( long time )

g
General date/time pattern ( short time [...]

Easy way to Export dataset in Excel

Easy way to Export dataset in Excel

Fastest way to export dataset in excel format is:

DataSet dsExport = new DataSet();
System.IO.StringWriter tw = new System.IO.StringWriter();
HTMLTextWriter hw = new HTMLTextWriter(tw);
DataGrid dg = new DataGrid();
dg.DataSource = "Dataset to be exported"
hw.WriteLine ("<b><font size=’3′>Exported report</font></b>");
dg.DataBind();
Response.ContentType = "application/vnd.ms-excel";
EnableViewState = false;
Response.Write(tw.ToString());
Response.End();

Crystal Report Viewer width – Visual Studio

Crystal Report Viewer width – Visual Studio

By default Crystal report viewer width is fixed according to it toolbar, but changes due to amount of data present in the report. And the width is not editable (as it is seen). Because of this reason if a crystal report has good amount of data then it goes past page width and disturbs the [...]

MS Charts in Visual Studion 2008

MS Charts in Visual Studion 2008

Looking for some good looking and lightweight charting control to be used with VS 2008 applications.
I have checked the following article on adding an using MS Charts control in vs 2008. It contains all the basic information regarding the creation and implementation of ms chart controls.
MS Charts
MS Charts Download
Chart Templates

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first

This annoying error comes up when using some smtp server that uses SSL.
A simple implementation to configure smtp settings in an ASP.NET web application is to add these setting in the specific "MailSettings" tag of Web.config file. I had also declared all the settings in web.config file but still I get this every time i [...]

Securing ASP.NET Web applications - Beginner's article

Securing ASP.NET Web applications – Beginner’s article

Want to secure a web application. A very good article relating to ASP.NET web application security hacks, and prevention techniques are defined at a beginner level. A good article for beginners, those who want to secure their applications.
Article Here

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154

Sometimes when working with office Interop assemblies the above mentioned error occurs. I had also got the same when using Microsoft Excel interop assembly and adding its reference in my ASP.NET application.

 
 
 
The problem is that by default when Microsoft Excel is used as a COM object then it can only be activated by the [...]

displaying an image for error message in ASP.NET validator control

displaying an image for error message in ASP.NET validator control

There are many instances when user wants to see interactive and elegant images in their websites, either they look at any of the controls, or the whole page itself. In ASP.NET validator controls, mostly it is seen that "*" is placed when an error has occured. Can we add some image to [...]

How to validate ReCAPTCHA.

How to validate ReCAPTCHA.

There are some cases when a user want to validate a CAPTCHA and perform some activity on its results. ReCAPTCHA gives an .NET API to perform some operations on its CAPTCHA component. Following is the code to validate a CAPTCHA on server side.
ASPX Markup:
<!– Start ReCAPTCHA –> <span class="orangetext">Captcha Verification:</span> [...]

70-528 exam dumps

70-528 exam dumps

Service Unavailable -  Error message

Service Unavailable – Error message

When you configure your IIS webserver and find the following message Service Unavailable Then the first solution to the above error is http://support.microsoft.com/default.aspx?id=823552 but if this does not solve the problem try doing the following stuff. Open the IIS Manager, right click Web Sites [...]

Remote Access Timeout

Remote Access Timeout

When using remote access you may find that uploading or downloading a large file or a group of files will cause the connection to time out before the operation finishes with the error message "The remote connection to the computer timed out. Please connect again."
By default, remote access is configured to timeout after 20 minutes, [...]

charachter validation and count for a textbox - Javascript

charachter validation and count for a textbox – Javascript

Here I have provided a solution to put a counter for a textbox, that can be updated as each character typed into the textbox. This script will also validate the maximum character length allowed for a textbox. This script will also work when anyone copy/paste the text into the textbox. Textbox can be either single [...]

Enable/Disable DIV tags through Javascript

Enable/Disable DIV tags through Javascript

Copy/Paste following javascript code snippet.
<script type="text/javascript"> function toggleAlert() { toggleDisabled(document.getElementById("content")); } function toggleDisabled(el) { try { el.disabled = el.disabled ? [...]

ASP.NET Caching -Improving Performance - Output Cache

ASP.NET Caching -Improving Performance – Output Cache

What is Output Cache?
Output cache is a mechanism that keep a copy of a rendered ASP.NET web page in memory. This behavior helps to improve performance by returning a response of the cached web page instantly and by reducing the need to render the page in every client request. If a page takes a lot [...]

Passing Querystring Parameters to a Silverlight Control

Passing Querystring Parameters to a Silverlight Control

The approach to passing Querystring parameters to a Silverlight 2.0 Control that works for me is pretty simple. We check for the presence of Querystrings in the app.xaml Application_Startup using the Silverlight HTML Bridge and pass those values to the page’s constructor.
APP.XAML ——————————–
private void Application_Startup(object sender, StartupEventArgs e) { [...]

ASP.NET Custom Control Lifecycle

ASP.NET Custom Control Lifecycle

I always forget the lifecycle of custom server control classes with respect to web page, ie. aspx file.
The following results are based on a drop down list custom control:
customcontrol – Constructor customcontrol – OnInit – Enter customcontrol – OnInit – Exit webpage – OnInit [...]

AJAX Tab Container - Style Problem

AJAX Tab Container – Style Problem

Cause Since the release of ASP.Net 2.0, all the pages’ DTD are set to XHTML 1.0 Transitional by default. Consequently, AJAX Control Toolkits were also created to adhere with standard. All the rendered AJAX controls will follow the said document type definition. As it turns out, [...]