Infolink

 

Search This Blog

Showing posts with label chiragkanzariya. Show all posts
Showing posts with label chiragkanzariya. Show all posts

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");
    }
 

Stop default Auto-Complete of ASP.net TextBox on all browser

If you use textBox properties AutoCompleteType="Disabled" it disables the autocompletes of textBox on only Internet explorer. There's another way to stop auto-complete on all browsers. Use autocomplete="off" on from tag instead of AutoCompleteType = "Disabled". Again you can use the TextBox1.Attributes.Add("autocomplete", "off"); to stop auto-complete on only specific TextBox control.

So, my findings are use the following code to stop autocomplete on specific control

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.

Creating a UserControl

we will be building a UserControl for displaying information about a community user.
First of all, let's add a UserControl to our project. In your Visual Studio or Visual Web Developer, you should be able to right click on your project and select Add new item.. A dialog will pop up, and you should select the Web User Control from the list of possible things to add. Let's call our UserControl UserInfoBoxControl, with the filename of UserInfoBoxControl.ascx. Make sure that you have checked the checkbox which places code in a separate file, the so-called CodeBehind file.

You should now have a UserInfoBoxControl.ascx and a UserInfoBoxControl.ascx.cs in your project. The first is where we put our markup, and the second is our CodeBehind file. Now, if UserInfoBoxControl.ascx is not already open and selected, do so now. You will see only one line of code, the UserControl declaration. As mentioned, this control will be displaying information about a user, so let's get started adding some markup to do so:

ASP.net Ajax

ASP.net Ajax is Microsoft's free framework for creating Ajax (Asynchronous Javascript and XML) web applications. At its simplest, it lets ASP developers do this - or add Ajax controls to their existing applications - without leaving their familiar drag-and-drop environment, and without having to understand Javascript or asynchronous communication with the host. According to the O'Reilly Network, it protects developers from "the underlying gibberish that makes it [Ajax] all work".

Oct 10, 2012

View State Rendering

The problem in earlier versions is that the viewstate is rendered at the bottom of the page.
If the page is posted back before the entire page is loaded, the viewstate that is being submitted back to the server is incomplete and thus invalid.

This was fixed with .NET 3.5 SP1.

But You can Fix it by below Render function in earlier version of .NET

Related Posts Plugin for WordPress, Blogger...