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.
2 . 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 () );
3 . How to include multiple vb/cs files in the source?
You can do this using assembly directives.
<%@ assembly src="test1.vb" %>
<%@ assembly src="test2.vb" %>
or
<%@ assembly src="test1.cs" %>
<%@ assembly src="test2.cs" %>
However, note that each source file will be compiled individually into its own assembly, so they cannot have dependencies on each other.
4 . How to convert a string to Proper Case?
Use the namespace System.Globalization VB.NET
Dim myString As String = "syncFusion deVeloPer sUppOrt"
' Creates a TextInfo based on the "en-US" culture.
Dim TI As TextInfo = New CultureInfo("en-US", False).TextInfo
Response.Write(TI.ToTitleCase(myString))
C#
string myString = "syncFusion deVeloPer sUppOrt";
// Creates a TextInfo based on the "en-US" culture.
TextInfo TI = new CultureInfo("en-US",false).TextInfo;
6 . Why do I get the error message "System.InvalidOperationException: It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a ...."?
You can't use MsgBox or MessageBox.Show in ASP.NET WebForm. You maybe use: VB.NET
)
C#
) ;
7 . 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;
}
8 . Are namespaces and Class names Case Sensitive?
Namespaces and Class names are case Sensitive. Namespaces imported using the @ Import Directive will cause an error if the correct case is not used.
9 . How to convert string to a DateTime and compare it with another DateTime?
VB.NET
Dim blntimeIsOk As Boolean = DateTime.Parse("15:00") <>
Response.Write(blntimeIsOk)
C#
bool blntimeIsOk = (DateTime.Parse("15:00") <>
Response.Write (blntimeIsOk);
10 . How to get the url of page dynamically?
Use Request.Url property
11 . How to convert user input in dMy format to Mdy?
VB.NET
Dim dt As DateTime = DateTime.ParseExact("0299", New String() {"My", "M/y"}, Nothing, System.Globalization.DateTimeStyles.None)
C#
DateTime dt = DateTime.ParseExact("0299", new string[] {"My","M/y"}, null,System.Globalization.DateTimeStyles.None);
12 . When the User is prompted a File Download dialogbox, if the user selects "Save" then the "Save as" dialog box is displayed. Is there any way for me to retrieve the filename and directory path specified by the user on the File Download dialog box?
Clients do not report information back about where the user selects to save the content, so there isn't an easy way to do this. Instead, you would need to ask the user before using the content-disposition for a file path, and then you could specify the filename parameter for the content-disposition header. Still, the user is free to change that path when actually downloading.
13 . How to hide or show Controls in server side code?
In any appropriate event write VB.NET
TextBox1.Visible =not TextBox1.Visible
C#
TextBox1.Visible =!TextBox1.Visible ;
14 . How to check if the user is using a secure or non secure connection?
The Request Object defines a Property called IsSecureConnection, that will indicate whether http:// or https:// has been used.
15 . Is it possible to write code in many languages in one ASP.NET project?
You cannot write the code-behind files in different languages in the same project, but you can write the aspx pages and ascx controls in different languages.
16 . What is the difference between Response.Redirect() and Server.Transfer().
Response.Redirect
Tranfers 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 transfered 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
17 . How to get the hostname or IP address of the server?
The first one should return the name of the machine, the second returns the local ip address. Note that name of the machine could be different than host, since your site could be using host headers
18 . What is the meaning of validateRequest=true in .net framework1.1?
The value of validateRequest is set to 'true' by default, which means that the framework will automatically deny submission of the '<' and '>' characters.
19 . What is the different between <%# %> and <%= %>?
The <%# %> is used for databinding where as <%= %> is used to output the result of an expression. The expression inside <%# %> will be executed only when you call the page's or control's DataBind method. The expression inside <%= %> will be executed and displayed as and when it appears in the page.
20 . What permissions do ASP.NET applications posses by default?
By default ASP.NET Web applications run as ASP.NET user. This user has limited permissions equivalent to the User Group.
21 . How can I specify the relative path for a file?
Suppose you have following file hierarchy:
default.aspx
Admin/login.aspx
Misc/testpage.aspx
And you are on the login.aspx and want your user to navigate to the default.aspx (or testpage.aspx) file. Then you can use
Response.Redirect ("../default.aspx")
Response.Redirect ("../Misc/testpage.aspx")
22 . How can I specify the "upload a file" input textbox in a form to be read only so that the user can click on the browse button and pick a file but they cannot type anything into the textbox next to the browse button.
23 . How to change the Page Title dynamically?
VB.NET
'Declare
Protected WithEvents Title1 As System.Web.UI.HtmlControls.HtmlGenericControl
24 . Why do I get the error message "Object must implement IConvertible". How can I resolve it?
The common cause for this error is specifying a control as a SqlParameter's Value instead of the control's text value. For example, if you write code as below you'll get the above error:
VB.NET
Dim nameParameter As SqlParameter = command.Parameters.Add("@name", SqlDbType.NVarChar, 50)
To resolve it, specify the control's Text property instead of the control itself.
VB.NET
nameParameter.Value = txtName.Text
C#
nameParameter.Value =txtName.Text;
25 . Why is default.aspx page not opened if i specify http://localhost. I am able to view this page if i hardcode it as http://localhost/default.aspx?
If some other default page comes higher in the list, adjust the default.aspx to be the number one entry inside the IIS configuration. If you have multiple websites inside IIS, make sure the configuration is applied on the right website (or on all websites by applying the configuration on the server-level using the properties dialog, configure WWW service).
28 . How to automatically get the latest version of all the asp.net solution items from Source Safe when opening the solution?
In VS.NET you can go to Tools > Options > Source Control > General and check the checkbox for Get everything when a solution opens. This retrieves the latest version of all solution items when you open the solution.
29 . How to make VS.Net use FlowLayout as the default layout rather than the GridLayout?
For VB.NET, go to path C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\WebForm\Templates\1033 Change the following line in the existing WebForm1.aspx
to
For C#, go to path C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpWebAppWiz\Templates\1033 Change the following line in the existing WebForm1.aspx
to
Note:Before changing any templates it's a good idea to make backup copies of them Or rather than above approach you can change the behavior for new files on a per project basis in Visual Studio by:
Right clicking on the project name (Ex: "WebApplication1)" in Solution Explorer, and select "Properties".
From project properties window, under Common Properties>Designer Defaults>Page Layout change "Grid" to "Flow".
30 . Can I use a DataReader to update/insert/delete a record?
No. DataReader provides a means of reading a forward-only stream of rows from a database.
31 . How to format a Telphone number in the xxx-xxx-xxxx format?
VB.NET
Dim Telno As Double = Double.Parse(ds.Tables(0).Rows(0)("TelNo").ToString())
32 . Can two different programming languages be mixed in a single ASPX file?
No. ASP.NET uses parsers to strip the code from ASPX files and copy it to temporary files containing derived Page classes, and a given parser understands only one language
33 . Can I use custom .NET data types in a Web form?
Yes. Place the DLL containing the type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced. This is also what happens when you add a custom control from the toolbox to your web form.
34 . How can I have a particular Web page in an ASP.NET application which displays its own error page.
This can be done by setting the ErroPage attribute of Page Directive or ErrorPage property of Page Class to the desired Custom Error Page