Infolink

 

Search This Blog

Showing posts with label asp.net blog. Show all posts
Showing posts with label asp.net blog. Show all posts

Oct 19, 2012

ASP.NET Trace

Trace.Write helps diagnose problems in ASP.NET. It determines what is actually running in an ASP.NET application. We review the basics of tracing in ASP.NET. We use the C# language to easily benchmark sites.

First we must add the trace markup to our Web.config file. The sample values in the markup I show can and should be changed by you. I encourage you to flip the attribute values and see what they do as much as possible. Here's how to add the markup.

Open Web.config file. Your ASP.NET project should have a Web.config file. If it doesn't, add one through the Website > Add New Item.... menu. This is an XML file used by ASP.NET to store website configuration settings.

Oct 18, 2012

How to use C# HashTable Class

Hashtable in C# represents a collection of key/value pairs which maps keys to value. Any non-null object can be used as a key but a value can. We can retrieve items from hashTable to provide the key . Both keys and values are Objects.

The commonly used functions in Hashtable are :

  Add                   : To add a pair of value in HashTable
  ContainsKey    : Check if a specified key exist or not
  ContainsValue  : Check the specified Value exist in HashTable


Remove : Remove the specified Key and corresponding Value

Add : To add a pair of value in HashTable

Syntax : HashTable.Add(Key,Value)
  Key : The Key value
  Value : The value of corresponding key
  Hashtable ht;

ht.Add("1", "Sunday");

Oct 16, 2012

ASHX handler in Asp.Net

An ASHX handler allows you a discrete http handler without the overhead of processing a page request (an ASPX file).

<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;

public class Handler : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        var fileName = "must.sql";
        var r = context.Response;
        r.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
        r.ContentType = "text/plain";
        r.WriteFile(context.Server.MapPath(fileName));

    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}
 Now, You have to create button in your .aspx page write the code as following

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Handler.ashx");
    }
 

Oct 15, 2012

RAISERROR statement in SQL server

RAISERROR statement is used to return error messages to the business applications that executes SQL statements. The usual errors returned by the SQL server may not make much sense to the business applications users hence we overwrite it by using RAISERROR to display meaningful messages. The statement uses same format as a system error or warning messages generated by SQL server.

You can return a user-defined error message by using RAISERROR.  The general syntax is as below

Oct 14, 2012

Spell as you Type plug-in

Full clientside spell checker for IE 6.0+ users that underlines misspellt words as you type into a textbox or textarea. Right click to see a list of suggested corrections.

Browsers such as Firefox and Chrome have spell as you type built in, this plugin will not have any effect in other browsers.

Use the dictionary supplied or create you own (plain text file, one word per line) using the dictionary builder application. The dictionaries supplied are over 500k each, so enable caching (and compression if available) on the server.
Related Posts Plugin for WordPress, Blogger...