asp.net,vb.net,c #,faq's,real time questions, dot net frame work,microsoft dot net,dot net tutorial, dot net certification,debugging,dot net tips,dot net programes,dot net lessons,dot net faq's,interview questions,ado.net,asp.net,Visual Basic.net,sql server microsoft,visual basic net,net applications & microsoft dot net architecture. Yellow pages,Gurgaon Yellow Pages,Education,Gurgaon Classifieds, Hotels in Gurgaon
Dot Net FAQ
Welcome
BASIC
What is ASP.NET?
ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications.
What is ASP.NET?
ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications. ASP.NET offers several important advantages over previous Web development models:
* Enhanced Performance. ASP.NET is compiled common language runtime code running on the server. Unlike its interpreted predecessors, ASP.NET can take advantage of early binding, just-in-time compilation, native optimization, and caching services right out of the box. This amounts to dramatically better performance before you ever write a line of code.
* World-Class Tool Support. The ASP.NET framework is complemented by a rich toolbox and designer in the Visual Studio integrated development environment. WYSIWYG editing, drag-and-drop server controls, and automatic deployment are just a few of the features this powerful tool provides.
* Power and Flexibility. Because ASP.NET is based on the common language runtime, the power and flexibility of that entire platform is available to Web application developers. The .NET Framework class library, Messaging, and Data Access solutions are all seamlessly accessible from the Web. ASP.NET is also language-independent, so you can choose the language that best applies to your application or partition your application across many languages. Further, common language runtime interoperability guarantees that your existing investment in COM-based development is preserved when migrating to ASP.NET.
* Simplicity. ASP.NET makes it easy to perform common tasks, from simple form submission and client authentication to deployment and site configuration. For example, the ASP.NET page framework allows you to build user interfaces that cleanly separate application logic from presentation code and to handle events in a simple, Visual Basic - like forms processing model. Additionally, the common language runtime simplifies development, with managed code services such as automatic reference counting and garbage collection.
* Manageability. ASP.NET employs a text-based, hierarchical configuration system, which simplifies applying settings to your server environment and Web applications. Because configuration information is stored as plain text, new settings may be applied without the aid of local administration tools. This "zero local administration" philosophy extends to deploying ASP.NET Framework applications as well. An ASP.NET Framework application is deployed to a server simply by copying the necessary files to the server. No server restart is required, even to deploy or replace running compiled code.
* Scalability and Availability. ASP.NET has been designed with scalability in mind, with features specifically tailored to improve performance in clustered and multiprocessor environments. Further, processes are closely monitored and managed by the ASP.NET runtime, so that if one misbehaves (leaks, deadlocks), a new process can be created in its place, which helps keep your application constantly available to handle requests.
* Customizability and Extensibility. ASP.NET delivers a well-factored architecture that allows developers to "plug-in" their code at the appropriate level. In fact, it is possible to extend or replace any subcomponent of the ASP.NET runtime with your own custom-written component. Implementing custom authentication or state services has never been easier.
* Security. With built in Windows authentication and per-application configuration, you can be assured that your applications are secure.
Why does my ASP.NET file have multiple
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."
How to find out what version of ASP.NET I am using on my machine?
VB.NET
Response.Write(System.Environment.Version.ToString() )
C#
Response.Write(System.Environment.Version.ToString() );
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"%>
.aspx
VB.NET
Response.Write (Request("id").ToString ())
C#
Response.Write (Request["id"].ToString ());
What is a ViewState?
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 runat="server" control.
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.
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
What is the equivalent of date() and time() in ASP.NET?
VB.NET
System.DateTime.Now.ToShortDateString()
System.DateTime.Now.ToShortTimeString()
C#
System.DateTime.Now.ToShortDateString();
System.DateTime.Now.ToShortTimeString();
How to prevent a button from validating it's form?
Set the CauseValidation property of the button control to False
How to get the IP address of the host accessing my site?
VB.NET
Response.Write (Request.UserHostAddress.ToString ())
C#
Response.Write (Request.UserHostAddress.ToString ());
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")
C#
Request.QueryString["id"];
How to Set Focus to Web Form Controls By Using Client-Side Script?
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
'your code
'Response.Redirect("err404.aspx")
Else
'your code
End If
C#
Exception ex = Server.GetLastError().GetBaseException();
if (ex.GetType() == typeof(System.IO.FileNotFoundException))
{
//your code
Response.Redirect ("err404.aspx");
}
else
{
//your code
}
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.
How to Compare time?
VB.NET
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())
Else
Response.Write(t1.ToString() & " is > than " & t2.ToString())
End If
C#
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());
}
else
{
Response.Write(t1.ToString() + " is > than " + t2.ToString());
}
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.
How to get URL without querystring?
VB.NET
Dim stringUri As String = "http://www.syncfusion.com/?id=1&auid=16"
Dim weburi As Uri = New Uri(stringUri)
Dim query As String = weburi.Query
Dim weburl As String = stringUri.Substring(0, stringUri.Length - query.Length)
Response.Write(weburl)
C#
string stringUri = "http://www.syncfusion.com/?id=1&auid=16";
Uri weburi = new Uri(stringUri);
string query = weburi.Query;
string weburl = stringUri.Substring(0, stringUri.Length - query.Length);
Response.Write (weburl);
What is the best way to output only time and not Date?
Use DateTime as follows VB.NET
Response.Write(DateTime.Now.ToString("hh:mm:ss"))
C#
Response.Write(DateTime.Now.ToString("hh:mm:ss"));
What is the difference between Absolute vs Relative URLs?
Absolute /Fully Qualified URLs:
* Contain all information necessary for the browser(or other client program) to locate the resource named in the URL
o This includes protocol moniker used( i.e http://, ftp://..etc..), Server's Domain name or IP address and the file path
o Absolute URL looks as http://localhost/syncfusion/page1.aspx
Relative URLs:
* Only provide information necessary to locate a resource relative to the current document(document relative) or current server or domain(root relative)
o Document relative URL - page1.aspx
o Root Relative URL - /syncfusion/Admin/pagelog.aspx
What is the difference between URL and URI?
A URL is the address of some resource on the Web, which means that normally you type the address into a browser and you get something back. There are other type of resources than Web pages, but that's the easiest conceptually. The browser goes out somewhere on the Internet and accesses something.
A URI is just a unique string that uniquely identifies something, commonly a namespace. Sometimes they look like a URL that you could type into the address bar of your Web browser, but it doesn't have to point to any physical resource on the Web. It is just a unique set of characters, that, in fact, don't even have to be unique.
URI is the more generic term, and a URL is a particular type of URI in that a URL has to uniquely identify some resource on the Web.
How to convert milliseconds into time?
VB.NET
dim ts as TimeSpan = TimeSpan.FromMilliseconds(10000)
Response.Write (ts.ToString () )
C#
TimeSpan ts = TimeSpan.FromMilliseconds(10000);
Response.Write (ts.ToString () );
How to validate that a string is a valid date?
VB.NET
Dim blnValid As Boolean = False
Try
DateTime.Parse(MyString)
blnValid = True
Catch
blnValid = False
End Try
C#
bool blnValid=false;
try
{
DateTime.Parse(MyString);
blnValid=true;
}
catch
{
blnValid=false;
}
What is the difference between Response.Redirect() and Server.Transfer().
Response.Redirect
* Transfers the page control to the other page, in other words it sends the request to the other page.
* Causes the client to navigate to the page you are redirecting to. In http terms it sends a 302 response to the client, and the client goes where it's told.
Server.Transfer
* Only transfers the execution to another page and during this you will see the URL of the old page since only execution is transferred to new page and not control.
* Occurs entirely on the server, no action is needed by the client
Sometimes for performance reasons, the server method is more desirable
What is the difference between Server.Transfer and Server.Execute?
* Server.Transfer is used to End the current weform and begin executing a new webform. This method works only when navigating to a Web Forms page (.aspx)
* Server.Execute is used to begin executing a new webform while still displaying the current web form. The contents of both forms are combined. This method works only when navigating to a webform page(.aspx)
How to format a Telephone number in the xxx-xxx-xxxx format?
VB.NET
Dim Telno As Double = Double.Parse(ds.Tables(0).Rows(0)("TelNo").ToString())
Response.Write(Telno.ToString("###-###-####"))
C#
double Telno= double.Parse(ds.Tables[0].Rows[0]["TelNo"].ToString());
Response.Write(Telno.ToString("###-###-####"));
How can we programmatically verify whether the UserName and Password is Correct?
The programmatic verification of username and password can be done by the below code by the Login1_Authenticate method
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
if((Login1.UserName=="User")&&(Login1.Password=="Password"))
{
Label1.Text="LogIn Successful";
}
else
{
Label1.Text="LogIn Failed - Try Again";
}
}
Labels:
BASIC
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment