|
|
ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications.
For more details refer
|
3.2 Why does my ASP.NET file have multiple <form> tag with runat=server?
|
 |
This means that ASP.Net is not properly registered with IIS.
.Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe
|
use the command: aspnet_regiis.exe -u ---> to uninstall current asp.net version.
|
use the command: aspnet_regiis.exe -i ---> to install current asp.net version.
|
For Windows Server 2003, you must use aspnet_regiis -i -enable
This is because of the "Web Service Extensions" feature in IIS 6
(if you install VS.NET or the framework without IIS installed, and then go back in and install IIS afterwards, you have to re-register so that ASP.NET 'hooks' into IIS properly."
|
3.3 How to find out what version of ASP.NET I am using on my machine?
|
 |
Response.Write(System.Environment.Version.ToString() )
|
Response.Write(System.Environment.Version.ToString() );
|
3.4 Is it possible to pass a querystring from an .asp page to aspx page?
|
 |
Yes you can pass querystring from .asp to ASP.NET page
.asp
|
<%response.redirect "webform1.aspx?id=11"%>
|
Response.Write (Request("id").ToString ())
|
Response.Write (Request["id"].ToString ());
|
3.5 How to comment out ASP.NET Tags?
|
 |
<%--<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 48px" runat="server">Label</asp:Label>--%>
|
In classic ASP, when a form is submitted the form values are cleared.
In some cases the form is submitted with huge information. In such cases if the server comes back with error, one has to re-enter correct information in the form. But submitting clears up all form values. This happens as the site does not maintain any state (ViewState).
In ASP .NET, when the form is submitted the form reappears in the browser with all form values. This is because ASP .NET maintains your ViewState.
ViewState is a state management technique built in ASP.NET. Its purpose is to keep the state of controls during subsequent postbacks by the same user.
The ViewState indicates the status of the page when submitted to the server. The status is defined through a hidden field placed on each page with a <form runat="server"> control.
|
<input type="hidden" name="__VIEWSTATE" value="dDwyNTA3OTU0NDM7Oz7t5TntzkOUeB0QVV6FT2hvQwtpPw==" />
|
If you want to NOT maintain the ViewState, include the directive <%@ Page EnableViewState="false"%> at the top of an .aspx page
If you do not want to maintain Viewstate for any control add the attribute EnableViewState="false" to any control.
For more details refer The ASP.NET View State
|
3.7 Where can I get the details on Migration of existing projects using various technologies to ASP.NET?
|
 |
Microsoft has designed Migration Assistants to help us convert existing pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration.
Below are the Code Migration Assistants
- ASP to ASP.NET Migration Assistant
- PHP to ASP.NET Migration Assistant
- JSP to ASP.NET Migration Assistant
Refer Migrating to ASP.Net |
3.8 What is the equivalent of date() and time() in ASP.NET?
|
 |
System.DateTime.Now.ToShortDateString()
|
System.DateTime.Now.ToShortTimeString()
|
System.DateTime.Now.ToShortDateString();
|
System.DateTime.Now.ToShortTimeString();
|
3.9 How to prevent a button from validating it's form?
|
 |
Set the CauseValidation property of the button control to False |
3.10 How to get the IP address of the host accessing my site?
|
 |
Response.Write (Request.UserHostAddress.ToString ())
|
Response.Write (Request.UserHostAddress.ToString ());
|
3.11 How to access the Parameters passed in via the URL?
|
 |
Call the Request.QueryStringmethod passing in the key. The method will return the parameter value associated with that key.
VB.NET
|
Request.QueryString("id")
|
Request.QueryString["id"];
|
3.12 How to Set Focus to Web Form Controls By Using Client-Side Script?
|
 |
<script language="javascript">
|
// W3C approved DOM code that will work in all modern browsers
|
if (document.getElementById)
|
document.getElementById('txt2').focus();
|
// To support older versions of IE:
|
document.all("txt2").focus();
|
<body MS_POSITIONING="GridLayout" onload="SetFocus()">
|
<form id="Form1" method="post" runat="server">
|
<asp:TextBox ID="txt1" Runat="server" Width="50" />
|
<asp:TextBox ID="txt2" Runat="server" Width="50" />
|
<asp:Button id="Button1" runat="server" Text="Button1"></asp:Button>
|
3.13 How to display a Wait page while a query is running?
|
 |
3.14 How to implement Form based Authentication in ASP.NET application?
|
 |
3.15 How to catch the 404 error in my web application and provide more useful information?
|
 |
In the global.asax Application_error Event write the following code
VB.NET
|
Dim ex As Exception = Server.GetLastError().GetBaseException()
|
If TypeOf ex Is System.IO.FileNotFoundException Then
|
'Response.Redirect("err404.aspx")
|
Exception ex = Server.GetLastError().GetBaseException();
|
if (ex.GetType() == typeof(System.IO.FileNotFoundException))
|
Response.Redirect ("err404.aspx");
|
3.16 Is there a method similar to Response.Redirect that will send variables to the destination page other than using a query string or the post method?
|
 |
Server.Transfer preserves the current page context, so that in the target page you can extract values and such. However, it can have side effects; because Server.Transfer doesnt' go through the browser, the browser doesn't update its history and if the user clicks Back, they go to the page previous to the source page.
Another way to pass values is to use something like a LinkButton. It posts back to the source page, where you can get the values you need, put them in Session, and then use Response.Redirect to transfer to the target page. (This does bounce off the browser.) In the target page you can read the Session values as required.
Refer to Passing Values Between Web Forms Pages for more information. |
3.17 What are the differences between HTML versus Server Control?
|
 |
3.18 How can I change the action of a form through code?
|
 |
3.19 Is there any control that allows user to select a time from a clock - in other words is there a clock control?
|
 |
3.20 How to Compare time?
|
 |
Dim t1 As String = DateTime.Parse("3:30 PM").ToString("t")
|
Dim t2 As String = DateTime.Now.ToString("t")
|
If DateTime.Compare(DateTime.Parse(t1), DateTime.Parse(t2)) < 0 Then
|
Response.Write(t1.ToString() & " is < than " & t2.ToString())
|
Response.Write(t1.ToString() & " is > than " & t2.ToString())
|
string t1 = DateTime.Parse("3:30 PM").ToString("t");
|
string t2 = DateTime.Now.ToString("t");
|
if (DateTime.Compare(DateTime.Parse (t1), DateTime.Parse (t2)) < 0 )
|
Response.Write(t1.ToString() + " is < than " + t2.ToString());
|
Response.Write(t1.ToString() + " is > than " + t2.ToString());
|
3.21 How To work with TimeSpan Class?
|
 |
Dim adate As DateTime = DateTime.Parse("06/24/2003")
|
Dim bdate As DateTime = DateTime.Parse("06/28/2003")
|
Dim ts As New TimeSpan(bdate.Ticks - adate.Ticks)
|
Response.Write(ts.TotalDays & "<br>")
|
Response.Write(ts.TotalHours & ":" & ts.TotalMinutes & ":" & ts.TotalSeconds & ":" & ts.TotalMilliseconds)
|
DateTime adate = DateTime.Parse("06/24/2003");
|
DateTime bdate = DateTime.Parse("06/28/2003");
|
TimeSpan ts = new TimeSpan (bdate.Ticks - adate.Ticks);
|
Response.Write(ts.TotalDays.ToString () + "<br>");
|
Response.Write(ts.TotalHours.ToString() + ":" + ts.TotalMinutes.ToString() + ":" + ts.TotalSeconds.ToString() + ":" + ts.TotalMilliseconds.ToString() );
|
3.22 Where can I get information on Cookies in ASP.NET?
|
 |
3.23 Does ASP.Net still recognize the global.asa file?
|
 |
ASP.Net does not recognize the standard ASP global.asa file. Instead it uses a file named global.asax with the same - plus additional - functionality. |
3.24 How should I destroy my objects in ASP.Net?
|
 |
ASP.Net actually has very solid internal garbage collection. So this is not an issue as it was in previous versions of Active Server Pages.
Link to more information:
<gcConcurrent> Element
|
3.25 Are there resources online with tips on ASP to ASP.Net conversions?
|
 |
Microsoft has designed The ASP to ASP.NET Migration Assistant help us convert ASP pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration.
The following Code Migration Assistants are discussed in the link below.
- ASP to ASP.NET Migration Assistant
- PHP to ASP.NET Migration Assistant
- JSP to ASP.NET Migration Assistant
Refer Migrating to ASP.Net
Also refer:
|
3.26 How do I publish my ASP.NET application to my ISP's web server?
|
 |
3.27 Why do i get error message "Could not load type" whenever I browse to my ASP.NET web site?
|
 |
3.28 Will the WebMatrix SqlDataSourceControl work with a MySQL connection?
|
 |
SqlDataSourceControl lets you connect and work with MS SQL DB, while AccessDataSourceControl do the same thing but for MS Access DB.
Therefore SqlDataSourceControl can't help you in your MySql connectivity .
For Connectivity with MySql refer Accessing MySQL Database with ASP.NET
|
3.29 Can I combine classic ASP and ASP.NET pages?
|
 |
No.
ASP pages can run in the same site as ASP.NET pages, but you can't mix in a page.
Also ASP and ASP.NET won't share their session. |
3.30 What is the difference between src and Code-Behind?
|
 |
Src attribute means you deploy the source code files and everything is compiled JIT (just-in-time) as needed.
Many people prefer this since they don't have to manually worry about compiling and messing with dlls -- it just works.
Of course, the source is now on the server, for anyone with access to the server -- but not just anyone on the web.
CodeBehind attribute doesn't really "do" anything, its just a helper for VS.NET to associate the code file with the aspx file.
This is necessary since VS.NET automates the pre-compiling that is harder by hand, and therefore the Src attribute is also gone.
Now there is only a dll to deploy, no source, so it is certainly better protected, although its always decompilable even then.
|
3.31 How can I get the value of input box with type hidden in code-behind?
|
 |
You can set the runat= server for the hidden control and you can use ControlName.Value to get its value in CodeBehind file |
3.32 I have created a .NET user control page (.ascx) but I cannot compile and run it.
|
 |
User control (ascx) can't be run on it own, but you can drag it onto any web page (aspx) and then run it. |
3.33 What is a .resx file?
|
 |
The .resx resource file format consists of XML entries, which specify objects and strings inside XML tags. This is useful for localization.
For more details refer Resources in .resx files |
3.34 Is it possible to use a style sheet class directly on a control instead of using inline or page-level formatting ?
|
 |
Every WebControl derived control has a CssClass property which allows you to set it's format to a style sheet. |
3.35 Can I receive both HTML markup for page and code in the ASP.NET web page's source code portion in the Web browser?
|
 |
No. The Web browser receives only HTML markup.
No source code or web control syntax is passed back to the web browser. |
3.36 Why can't I put <%@ Page Language="C " %> where at the top of an ASPX file and write my server-side scripts in C ?
|
 |
The parsers ASP.NET uses to extract code from ASPX files understand C#, Visual Basic.NET, and JScript.NET. You can write server-side scripts in any language supported by a .NET compiler. |
3.37 ASP pages that worked perfectly on Windows 2000 Server and IIS 5.0 do not work on Windows 2003 Server with IIS 6.0. ASP.NET pages work fine. Why?
|
 |
Start -> Settings -> Control Panel -> Administrative Tools -> and double clicking IIS Manager.
Go to the Web Service Extensions tab, click Active Server Pages, then press the "Allow" button on the left |
3.38 Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -- The system cannot find the file specified"?
|
 |
Check the location of the key.snk file relative to the assembly file. Provide an explicit path or a relative path.
|
<Assembly: AssemblyKeyFileAttribute("Drive:\key.snk")>
|
3.39 How to get URL without querystring?
|
 |
| |