<html>
<head>
<style type="text/css">
#container_outer
{
width: 900px;
margin: 0 auto;
}
#container_top
{
height: 50px;
background-color: #555;
border-width:1px;
}
#container_bottom
{
height: 28px;
background-color: #555;
}
#container_middle
{
overflow: hidden;
background-color:lightgrey;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="container_outer">
<div id="container_top">
</div>
<div id="container_middle">
<br>
Sample Text
<br>
</div>
<div id="container_bottom">
</div>
</div>
</body>
</html>
see
ASP.Net [Tips & FAQ]
Friday, July 22, 2011
Make the page center to the browser window
Thursday, February 3, 2011
Error: customErrors -- How to Upload ASP.NET website on domain?
This website is properlly executing on my local computer. on uploading this website on webserver i got following error:
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's
plz.. Solve me the problem.. what i am getting...
Tuesday, December 14, 2010
MaxLength in TextBox control in ASP.Net
When I was use TextBOx with TextMode "MultiLine" and MaxLength "10".I can enter more than 10 characters. SO I use Java Script for that and it solve my problem.
JavaScript like this :
< language="javascript">
function limitCharsLength(Object, MaxLen)
{
return (Object.value.length <= MaxLen-1);
}
< /script >
and TextBox like this :
< asp:TextBox ID="TextBox1" runat="server" Height="173px" TextMode="MultiLine"
Width="369px" onkeypress="javascript: return limitCharsLength(this,5);"
onblur="javascript: limitCharsLength(this, 5)"
onchange="javascript : return limitCharsLength(this, 5)" >< /asp:TextBox >
Enable/Disable RequiredFieldValidator with Javascript
For that set EnableClientScript property of validator to True.
Here i give example for this:
I have a page with a couple of radio buttons.On radio button selection i want to enable/disable validation.
In example if i select Email radio button then Email div will display and only txtEmail textbox validator is enabled.
Java Script for this:
Code for this:
Email :
PhoneNo :
PhoneNo
Download File Dialog box
Code to open a "save as.." file download dialog box in asp.net 2.
Here,I create a vb.net function for to open file download dialog box.
Use System.IO class for file system. Function argument accepts a File virtual path not physical path.
This code for only .txt file but you also use this code for more extension file.For that change only ContentType.
.htm,.html => "text/HTML"
.txt => "text/plain"
.doc,.rtf => "Application/msword"
.csv,.xls => "Application/x-msexcel"
.pdf =>"Application/pdf"
Function DisplayDownloadDialog(ByVal PathVirtual As String)
Dim strPhysicalPath As String
Dim objFileInfo As System.IO.FileInfo
Try
strPhysicalPath = Server.MapPath(PathVirtual)
'exit if file does not exist
If Not System.IO.File.Exists(strPhysicalPath) _
Then Exit Function
objFileInfo = New System.IO.FileInfo(strPhysicalPath)
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
'Add Headers to enable dialog display
Response.AddHeader("Content-Disposition", "attachment; filename=" & _
objFileInfo.Name)
Response.AddHeader("Content-Length", objFileInfo.Length.ToString())
Response.ContentType = "Text / plain"
Response.WriteFile(objFileInfo.FullName)
Catch
'on exception take no action
'you can implement differently
Finally
Response.End()
End Try
End Function
Folders in ASP.NET 2.0
There are seven new folders introduced in ASP.NET 2.0 :
\App_Browsers folder – Holds browser definitions(.brower) files which identify the browser and their capabilities.
\App_Code folder – Contains source code (.cs, .vb) files which are automatically compiled when placed in this folder. Additionally placing web service files generates a proxy class(out of .wsdl) and a typed dataset (out of .xsd).
\App_Data folder – Contains data store files like .mdf (Sql Express files), .mdb, XML files etc. This folder also stores the local db to maintain membership and role information.
\App_GlobalResources folder – Contains assembly resource files (.resx) which when placed in this folder are compiled automatically. In earlier versions, we were required to manually use the resgen.exe tool to compile resource files. These files can be accessed globally in the application.
\App_LocalResources folder – Contains assembly resource files (.resx) which can be used by a specific page or control.
\App_Themes folder – This folder contains .css and .skin files that define the appearance of web pages and controls.
\App_WebReferences folder – Replaces the previously used Web References folder. This folder contains the .disco, .wsdl, .xsd files that get generated when accessing remote web services.
Page Directives in ASP.NET 2.0
Page directives configure the runtime environment that will execute the page. The complete list of directives is as follows:
@ Assembly - Links an assembly to the current page or user control declaratively.
@ Control - Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).
@ Implements - Indicates that a page or user control implements a specified .NET Framework interface declaratively.
@ Import - Imports a namespace into a page or user control explicitly.
@ Master - Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.
@ MasterType - Defines the class or virtual path used to type the Master property of a page.
@ OutputCache - Controls the output caching policies of a page or user control declaratively.
@ Page - Defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files.
@ PreviousPageType - Creates a strongly typed reference to the source page from the target of a cross-page posting.
@ Reference - Links a page, user control, or COM control to the current page or user control declaratively.
@ Register - Associates aliases with namespaces and classes, which allow user controls and custom server