Está en la página 1de 18

4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 4.13 4.14 4.

15 4.16 4.17 4.18 4.19 4.20 4.21 4.22 4.23 4.24 4.25 4.26 4.27 4.28 4.29 4.30 4.31 4.32 4.33 4.34 4.35 4.36 4.37 4.38 4.39 4.40 4.41 4.42 4.43 4.44 4.45 4.46 4.47 4.48 4.49 4.50 4.51 4.52 4.53

What is ASP.NET? Why does my ASP.NET file have multiple <form> tag with runat=server? How to find out what version of ASP.NET I am using on my machine? Is it possible to pass a querystring from an .asp page to aspx page? How to comment out ASP.NET Tags? What is a ViewState? Where can I get the details on Migration of existing projects using various technologies to ASP.NET? What is the equivalent of date() and time() in ASP.NET? How to prevent a button from validating it's form? How to get the IP address of the host accessing my site? How to access the Parameters passed in via the URL? How to Set Focus to Web Form Controls By Using Client-Side Script? How to display a Wait page while a query is running? How to implement Form based Authentication in ASP.NET application? How to catch the 404 error in my web application and provide more useful information? 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? What are the differences between HTML versus Server Control? How can I change the action of a form through code? Is there any control that allows user to select a time from a clock - in other words is there a clock control? How to Compare time? How To work with TimeSpan Class? Where can I get information on Cookies in ASP.NET? Does ASP.Net still recognize the global.asa file? How should I destroy my objects in ASP.Net? Are there resources online with tips on ASP to ASP.Net conversions? How do I publish my ASP.NET application to my ISP's web server? Why do i get error message "Could not load type" whenever I browse to my ASP.NET web site? Can I combine classic ASP and ASP.NET pages? What is the difference between src and Code-Behind? Will the WebMatrix SqlDataSourceControl work with a MySQL connection? How can I get the value of input box with type hidden in code-behind? I have created a .NET user control page (.ascx) but I cannot compile and run it. What is a .resx file? Is it possible to use a style sheet class directly on a control instead of using inline or page-level formatting ? How to grab the referring URL? My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to .aspx? How can I save images ? How can I logout when using FormsAuthentication? How to get URL without querystring? Why can't I put <%@ Page Language="C " %> where at the top of an ASPX file and write my server-side scripts in C ? Why do I get a blank page when I use Server.Transfer("page1.htm") to transfer to a different page? How to detect the User's culture? What is the difference between CurrentCulture property and the CurrentUICulture property? 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? What is the best way to output only time and not Date? Do I have to compile code if I am changing the content of my aspx.cs file? Can I read the hard disk serial # of the client computer using ASP.NET? What is xxx(src As Object, e As EventArgs)? How can I ensure that application-level variables are not updated by more than one user simultaneously? Can I receive both HTML markup for page and code in the ASP.NET web page's source code portion in the Web browser? Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -The system cannot find the file specified"? What is the difference between Absolute vs Relative URLs? What is the difference between URL and URI?

4.54 4.55 4.56 4.57 4.58 4.59 4.60

4.61

4.62 4.63 4.64 4.65 4.66 4.67 4.68 4.69 4.70 4.71 4.72 4.73 4.74 4.75

4.76 4.77 4.78 4.79 4.80 4.81 4.82 4.83 4.84 4.85 4.86 4.87 4.88 4.89 4.90 4.91 4.92 4.93 4.94 4.95 4.96 4.97 4.98 4.99 4.100 4.101 4.102 4.103 4.104 4.105 4.106 4.107

How to convert milliseconds into time? How to include multiple vb/cs files in the source? How to convert a string to Proper Case? How to convert string to a DateTime and compare it with another DateTime? How to get the url of page dynamically? How to convert user input in dMy format to Mdy? 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 ...."? 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? How to hide or show Controls in server side code? How to validate that a string is a valid date? Are namespaces and Class names Case Sensitive? What is the difference between Response.Redirect() and Server.Transfer(). How to get the hostname or IP address of the server? What is the meaning of validateRequest=true in .net framework1.1? What is the different between <%# %> and <%= %>? How to check if the user is using a secure or non secure connection? Is it possible to write code in many languages in one ASP.NET project? What permissions do ASP.NET applications posses by default? 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? Can ASP.NET work on an NT server? How can I specify the relative path for a file? 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. How to change the Page Title dynamically? Why do I get the error message "Object must implement IConvertible". How can I resolve it? Is it possible to migrate Visual InterDev Design-Time Controls to ASP.NET? How to automatically get the latest version of all the asp.net solution items from Source Safe when opening the solution? How to convert the datetime into a string for use in the SQL ' statement? How to make VS.Net use FlowLayout as the default layout rather than the GridLayout? Can I use a DataReader to update/insert/delete a record? What is the difference between Server.Transfer and Server.Execute? How to create a login screen in ASP.NET? How to format a Telephone number in the xxx-xxx-xxxx format? Can two different programming languages be mixed in a single ASPX file? Can I use custom .NET data types in a Web form? How can I have a particular Web page in an ASP.NET application which displays its own error page. How to use absolute positioning for controls in a web page in VS2005? What is an Literal Control. How can we programmatically verify whether the UserName and Password is Correct? How to customize my site using WebParts? How to choose between Repeater, DataList and DataGrid? How to Manage Web Sites With ASP.NET? How to implement a "back" link on a web page? How can users Standardize their .NET Namespaces? How can users Visually Bind to Data in ASP.NET? Should users use DataReader or DataSet to retrieve data? How to Separate Form, Function, and Style? Can users create multiple interface applications? What are the tips for cloning ASP.NET web forms? How to boost web performance with multithreading? Can users use placeholder control in ASP.NET? Can users host ASP.NET applications? Could users page and sort Resultsets with ASP.NET? What are the tips on making ASP.NET design decisions? How can users use ASP.NET to make application development easy?

4.1 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.

For more details refer

y y

What is ASP.NET

ASP.NET OverView

4.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."

4.3 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() );

4.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"%>

.aspx VB.NET Response.Write (Request("id").ToString ())

C# Response.Write (Request["id"].ToString ());

4.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>--%>

4.6 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 <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

4.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

y y y

ASP to ASP.NET Migration Assistant

PHP to ASP.NET Migration Assistant

JSP to ASP.NET Migration Assistant

Refer Migrating to ASP.Net 4.8 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();

4.9 How to prevent a button from validating it's form?

Set the CauseValidation property of the button control to False

4.10 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 ());

4.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")

C# Request.QueryString["id"];

4.12 How to Set Focus to Web Form Controls By Using Client-Side Script? <script language="javascript"> function SetFocus() { // W3C approved DOM code that will work in all modern browsers if (document.getElementById) document.getElementById('txt2').focus(); else // To support older versions of IE: if (document.all) document.all("txt2").focus(); return false; } </script> <body MS_POSITIONING="GridLayout" onload="SetFocus()"> <form id="Form1" method="post" runat="server"> Enter 1: <asp:TextBox ID="txt1" Runat="server" Width="50" /> <br> Enter 2: <asp:TextBox ID="txt2" Runat="server" Width="50" /> <br> <asp:Button id="Button1" runat="server" Text="Button1"></asp:Button> </form> </body>

Refer Sample IE Code

4.13 How to display a Wait page while a query is running?

Refer Asynchronous Wait State Pattern in ASP.NET

4.14 How to implement Form based Authentication in ASP.NET application?

For

VB.NET

C#

4.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 '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 }

4.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.

4.17 What are the differences between HTML versus Server Control?

Refer

y y

ASP.NET Server Controls Recommendations

Introduction to ASP.NET Server Controls

4.18 How can I change the action of a form through code?

You can't change it. The action attribute is owned by ASP.NET. Handle Events and Transfer.

For work around refer to Paul Wilson's Multiple Forms and Non-PostBack Forms - Solution

4.19 Is there any control that allows user to select a time from a clock in other words is there a clock control?

Peter Blum has developed some controls. Check out Peter's Date Package: TimeOfDayTextBox and DurationTextBox Controls

4.20 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()); }

4.21 How To work with TimeSpan Class?

VB.NET 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)

C# 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() );

4.22 Where can I get information on Cookies in ASP.NET?

Refer Mike Pope's article Basics of Cookies in ASP.NET

4.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.

4.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

4.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

y y

PHP to ASP.NET Migration Assistant

JSP to ASP.NET Migration Assistant

Refer Migrating to ASP.Net Also refer:

y y y

Microsoft's ASP to ASP.NET Code Migration Assistant

John Peterson's article Microsoft's ASP to ASP.NET Migration Assistant

Paolo Cavone's article From ASP to ASP.NET... Painlessly!

4.26 How do I publish my ASP.NET application to my ISP's web server?

Your ISP must first create an IIS application and apply the Front Page Server Extensions to it. Then in Visual Studio .NET, select the "Project | Copy Project" menu. Then enter the URL and select the FrontPage web access method. The "Copy Project" feature copies all of the necessary files to your ISP's machine for your ASP.NET application to run.

You can also FTP your files to your ISP web server. But you must know which files to upload. For more details refer PRB: Remote ASP.NET Projects Require IIS on the Client Computer or FrontPage Server Extensions on the Server Computer

4.27 Why do i get error message "Could not load type" whenever I browse to my ASP.NET web site?

Your code-behind files for either your .aspx or the global.aspx page have not been complied. Use Visual Studio .NET's "Build | Build Solution" menu, or run the command line compiler.

For more details refer PRB: "Could not load type" error message when you browse to .aspx page

4.28 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.

4.29 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.

4.30 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 4.31 How can I get the value of input box with type hidden in codebehind?

You can set the runat= server for the hidden control and you can use ControlName.Value to get its value in CodeBehind file

4.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.

4.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

4.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.

4.35 How to grab the referring URL?

VB.NET Response.Write ( Request.UrlReferrer.ToString())

C# Response.Write ( Request.UrlReferrer.ToString());

4.36 My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to .aspx?

Use a <script runat=server> block instead of the <% %> syntax to define Subs. Make sure you have proper events associated with the code and have start and end of procedure or function written properly.

4.37 How can I save images ?

You need a stream to read the response, WebResponse.GetResponseStream(), and a stream to write it to the hard drive. FileStream should do the trick. You'll have to write to the filestream what you read from the response stream.

4.38 How can I logout when using FormsAuthentication?

VB.NET FormsAuthentication.SignOut()

C# FormsAuthentication.SignOut();

4.39 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);

4.40 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.

4.41 Why do I get a blank page when I use Server.Transfer("page1.htm") to transfer to a different page?

Server.Transfer only works with .aspx pages You can't use Transfer method with HTML pages

4.42 How to detect the User's culture?

VB.NET Dim sLang As String sLang = Request.UserLanguages(0) Response.Write(sLang)

C# string sLang ; sLang = Request.UserLanguages[0]; Response.Write (sLang);

4.43 What is the difference between CurrentCulture property and the CurrentUICulture property?

CurrentCulture property : affects how the .NET Framework handles dates, currencies, sorting and formatting issues

CurrentUICulture property : determines which satellite assembly is used when loading resources

4.44 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

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

4.46 Do I have to compile code if I am changing the content of my aspx.cs file?

Yes if you have used Codebehind="my.aspx.cs". Not if you used src="my.aspx.cs" in your page declaration.

4.47 Can I read the hard disk serial # of the client computer using ASP.NET?

No. Such information is not passed to the server with a http request.

4.48 What is xxx(src As Object, e As EventArgs)?

xxx is an event handler src is the object that fires the event e is an event argument object that contains more information about the event An event handler is used when one object wants to be notified when an event happens in another object

4.49 How can I ensure that application-level variables are not updated by more than one user simultaneously?

Use the HttpApplicationState's Lock and UnLock methods.

For more details refer : MSDN: Application State

4.50 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.

4.51 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")>

4.52 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

This includes protocol moniker used( i.e http://, ftp://..etc..), Server's Domain name or IP address and the file path

o
Relative URLs:

Absolute URL looks as http://localhost/syncfusion/page1.aspx

Only provide information necessary to locate a resource relative to the current document(document relative) or current server or domain(root relative)

Document relative URL - page1.aspx

Root Relative URL - /syncfusion/Admin/pagelog.aspx

4.53 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.

4.54 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 () );

4.55 How to include multiple vb/cs files in the source?

You can do this using assembly directives. <%@ <%@ or <%@ <%@ assembly src="test1.vb" %> assembly src="test2.vb" %> 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.56 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; Response.Write (TI.ToTitleCase( myString ));

For more details refer TextInfo.ToTitleCase()

4.57 How to convert string to a DateTime and compare it with another DateTime?

VB.NET Dim blntimeIsOk As Boolean = DateTime.Parse("15:00") < DateTime.Parse("08:00") Response.Write(blntimeIsOk)

C# bool blntimeIsOk = (DateTime.Parse("15:00") < DateTime.Parse("08:00")); Response.Write (blntimeIsOk);

4.58 How to get the url of page dynamically?

Use Request.Url property

4.59 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);

For more details refer DateTime.ParseExact

4.60 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 may use:

VB.NET Response.Write("<script>alert('Hello');</script>")

C# Response.Write("<script>alert('Hello');</script>") ;

También podría gustarte