|
Programs using the WebBrowser require that IE is installed
|
Total Hit (1931) |
If your program uses the WebBrowser control or any Microsoft Internet Control, you must ensure (and clearly specify in your app's documentation) that the program can only work on systems that have Internet Explorer installed. In fact, the WebBrowser control is embedded in the ShDocVw.Dll file, which
....Read More |
Rating
|
|
|
Silent install with VB6 Deployment and Packaging Wizard
|
Total Hit (2208) |
VB6 Deployment and Packaging Wizard's resulting setup.exe has a command line switch that allows for a silent install. This feature is virtually undocumented except in the source code for Setup1.exe. The default path for the project file of Setup1 is:
C:\Program Files\Microsoft Visual Studio\VB98\
....Read More |
Rating
|
|
|
Automatically hyperlink URLs in ASP.NET Pages
|
Total Hit (9922) |
Suppose that your ASP.NET pages display contents read from database fields. Suppose also that some of those fields may contain URLs or email addresses. A typical example is when you display user information such as the email address or the personal Web site. By using regular expressions, you can aut
....Read More |
Rating
|
|
|
Better user experience with the SmartNavigation property
|
Total Hit (3072) |
During a page postback, the page is redrawn by default and users see a short but annoying flickering. Worse, the scroll position isn't preserved during postbacks (the page scrolls to its top) and the first control on the page takes the input focus. This behavior contrasts with the experience that us
....Read More |
Rating
|
|
|
Creating a default button for the page
|
Total Hit (2606) |
It is usual for a web form to have more than one button control. How can you set the default button that should submit the form and raise its Click event on the server when the enter key is pressed on the form? The textbox and the other input controls don't have a property that allow you to specify
....Read More |
Rating
|
|
|
Creating a popup calendar control
|
Total Hit (9382) |
Many data entry forms have one or more text fields that the user should fill with a date value. Many sites have a button near these fields that when clicked pops up a new small window with a calendar, to help the user select the date. When the user clicks on a day (rendered as a hyperlink), this pop
....Read More |
Rating
|
|
|
Creating multi-steps input forms
|
Total Hit (2973) |
In a typical user registration form, you may ask for quite a lot of data, such as the first and last name, full address, phone and fax numbers, e-mail address, newsletters subscriptions and other data for the site personalization. All this data shouldn't the asked in a single step, because a long li
....Read More |
Rating
|
|
|
Disabling the session state to improve performances
|
Total Hit (2798) |
Sessions management consumes server's resources and memory, thus, if you don't use them in your application, you should disable them to improve performances. You can disable sessions for the entire application by setting to False the mode attribute in the web.config's <sessionState> tag, as follows:
....Read More |
Rating
|
|
|
Discern among servers with the MachineName property
|
Total Hit (2893) |
As in classic ASP, you can use the Server object from inside any ASP.NET application. This property returns a reference to an HttpServerUtility class.
The HttpServerUtility class exposes only two properties: ScriptTimeout (the timeout in seconds for a request) and the new MachineName property, wh
....Read More |
Rating
|
|
|
Don't preserve viewstate when doing a Server.Transfer
|
Total Hit (3078) |
The ASP.NET version of the Server.Transfer method accepts a second argument which, if true, causes the query string and all the form's fields to be transferred and made available to the destination page. However, when the destination page executes, the following error is likely to be generated:
....Read More |
Rating
|
|
|
Dynamically moving a server control
|
Total Hit (2833) |
Dynamically moving a server control instance on the page is very easy, thanks to the possibility to add any style attribute to the control. In this case, you can dynamically add the control's LEFT and TOP coordinates, and another attribute that says you want to use DHTML's absolute positioning. To t
....Read More |
Rating
|
|
|
Improve performance with the EnableViewState property
|
Total Hit (2796) |
All Web Forms controls, and the page itself, expose the EnableViewState property, a boolean that says whether the current value of the control must be saved in the __VIEWSTATE hidden field and restored during a page postback.
By default this property is True, which means that a field's value is
....Read More |
Rating
|
|
|
Input validation in ASP.NET 1.1
|
Total Hit (2706) |
ASP.NET 1.1 automatically validates input posted to the server against a list of potentially dangerous strings (the values are hard-coded, unfortunately, it would have been nice to be able to edit this list). For example, by default it prevents the user to submit text that contains "<script>", to pr
....Read More |
Rating
|
|
|
Parse URLs with the System.Uri class
|
Total Hit (3195) |
The Url and UrlReferrer properties of the Request ASP.NET object return a reference to the URL of the page and the URL of the page that referred to this one. Both properties return a System.Uri object; you can query the properties of this object to learn more about the address of the page that so yo
....Read More |
Rating
|
|
|
Passing values from a page to another by means of the Context object
|
Total Hit (2779) |
Sometimes you may want to gather the user input with a page, and process it in a different page. As you know, ASP.NET web forms can post only to themselves, so you can't just change the form's <i>action</i> attribute and make the form post to a different page. And anyway, you may want to do some pro
....Read More |
Rating
|
|
|
Persistent session state
|
Total Hit (2814) |
In ASP.NET 1.0 you have the option to maintain the session state on an external process, in SQL Server, by setting the mode attribute of the sessionState tag in web.config to SQLServer. The problem is that the data is stored in the SQL Server's Temp database, and thus the data is lost if the SQL Ser
....Read More |
Rating
|
|
|
Preload subject and body when offering an email URL
|
Total Hit (2906) |
You can easily add a link in your ASP and ASP.NET pages that, when clicked, runs the default mail program (e.g. Outlook) and allows the user to send a message to the email address you provide:
«Code LangId=4»
<a href=mailto:someone@yoursite.com>Click here to send a message</a>
«/Code»
Interes
....Read More |
Rating
|
|
|
Redirecting to the real referrer page during a postback
|
Total Hit (3423) |
Say that you have a page loaded from another page, and that in this page you have a "Save and Return" button that does something and returns to the previous page. For example you may have an Orders page that loads a Details page, where you make some changes and press the button to save the changes a
....Read More |
Rating
|
|
|
Saving data between postbacks in the ViewState collection
|
Total Hit (2648) |
In classic ASP, the only way to preserve information - for example, the value of a variable- - between consecutive client requests is by means of Session variables, cookies, or other awkward techniques, such as arguments on the query string or values in hidden fields.
ASP.NET gives you yet anoth
....Read More |
Rating
|
|
|
Saving HTTP requests for better debugging
|
Total Hit (2677) |
The new SaveAs method of the Request object saves the current HTTP request to a file, which can be very useful for logging and debugging reasons. You should pass True to its second argument if you want to save HTTP headers as well:
«Code LangId=4»
Request.SaveAs "c:\lastrequest.txt", True
«/Co
....Read More |
Rating
|
|
|
Sending files to the browser
|
Total Hit (2829) |
The ASP.NET Response object has been greatly expanded in its capability to send output to the client browser. For example, the WriteFile method can send the contents of any text, HTML, or XML file to the browser; in classic ASP you have to load the file in memory and then pass its contents to a Writ
....Read More |
Rating
|
|
|
The AutoPostBack property requires client-side scripting
|
Total Hit (2563) |
A few Web Forms control expose the AutoPostBack property, which makes it possible to start a postback when the user clicks on these controls or changes their contents. By default this property is False, but you can set it to True for the following controls: TextBox, CheckBox, RadioButton, CheckBoxLi
....Read More |
Rating
|
|
|
The MapPath method
|
Total Hit (2765) |
The ASP.NET Page object exposes the MapPath method, which converts a virtual path into a physical path, so it' is useful for passing arguments to objects that don't work with virtual paths:
«Code LangId=4»
Dim sr As New System.IO.StreamReader(Me.MapPath("/data/values.dat"))
«/Code»
You can al
....Read More |
Rating
|
|
|
Update the ACL of a file from an ASP.NET application
|
Total Hit (2698) |
It's not uncommon that ASP.NET applications have the need to use a personal .config file to write some runtime information. Since ASP.NET applications are not granted the permission to create or edit files on the server, the best place to store persistent data is a table in a database server (not an
....Read More |
Rating
|
|
|
Uploading a file on the server
|
Total Hit (4818) |
Uploading a file from the client to the server is very straightforward with ASP.NET. Just use the «code LangId=4»<input type="file" runat="server"> «/code»tag and its wrapper class HtmlInputFile. Here's how you define the control on the page:
«Code LangId=4»
<form runat="server" enctype="multipa
....Read More |
Rating
|
|
|
Using static variables instead of the Application object
|
Total Hit (3678) |
If you want to share a value or an object instance between all the pages of any session, you typically use the Application object. However, a good alternative is to use a public variable defined in a module (VB.NET only), or a static field/property defined in a class. Static properties maintain thei
....Read More |
Rating
|
|
|
Accessing user controls from the code-behind
|
Total Hit (2846) |
When you add a user control to an ASP.NET page, Visual Studio .NET does not add a control declaration as it does when you add standard ASP.NET web controls. The result is that you can't directly access the user control from the code-behind and programmatically change its properties and call its meth
....Read More |
Rating
|
|
|
Take advantage of COM+ object pooling
|
Total Hit (2742) |
VB6 objects can't be pooled under COM+, because they are apartment threaded. This restriction is void with VB.NET objects (and all .NET objects in general), because they are free-threaded. To make an object poolable you just need to decorate the class with the ObjectPooling attribute:
«Code LangI
....Read More |
Rating
|
|
|
Be careful when installing SHLWAPI.DLL with Visual Installer
|
Total Hit (1955) |
I happened to come across a serious problem when installing my own software with Visual Installer 1.1: the installation of my product on Windows 98 computers caused a system crash during the next Windows start-up. The only way to fix things was to reinstall Windows from CD, over the existent version
....Read More |
Rating
|
|
|
Out-of-date dependency file for COMCTL32.OCX
|
Total Hit (2158) |
Have you ever read a message like "Dependency file for COMCTL32.OCX is out of date" during the package creation process? The cause of this problem is simple: you have installed an application that has replaced your COMCTL32.OCX ActiveX with the newer release (which is 5.00.3828 at this time). The Ac
....Read More |
Rating
|
|