Archive for the ‘ASP.NET’ Category

Overcoming Flickering in PopupExtenders

July 25th, 2008 by koolb | No Comments | Filed in .NET, AJAX, ASP.NET, Programming, Web, Web Development

When ASP.NET Ajax popup extenders are used sometime you may see a small flickering in the form. You can avoid this by hiding the panel used by the popup controls using the following code block

PanelPopupControl.Style.Add(“display”, “none”);

Is it really required to show the User Name and Password in ASP.NET Error Page?

February 3rd, 2008 by koolb | No Comments | Filed in .NET, ASP.NET, Internet, Programming, Software Development, Web Development

I got the following ASP.NET error when I was browsing a local web site. The error is due to ASP.NET cannot authenticate using the User Name and password in the impersonate tag. Ther real issue is not the windows authentication problem. Because the reason for the error could be the domain server is down or the administrator has used an incorrect user name and password in the web.config.

But is it sill good to show the User Name and Password in the error message? You can argue that the developer has switched on CUSTOM ERROR MESSAGES and he has forgotten to switch it off at the time of deployment. But still is it really required to show the whole user name and password in the error? If the necessary ports are not secured, someone can easily login to the server and mess up the server very easily. (In this case only the port 80 and 21 is open and this user won’t have permission for FTP.)

mydaylk-aspnet-error-2.PNG

ASP.NET 2.0 Validation Controls

November 30th, 2006 by koolb | No Comments | Filed in .NET, ASP.NET, Programming, Web Development

ASP.NET 2.0 has not introduced any new validation controls but MS has enhanced the existing validation controls a lot

Validation Groups

Now you can have multiple form areas on the same page by grouping the controls to be validated by using ValidationGroup property of controls.

This feature supports server side validations too. In Addition Page.Validate() method has been enhanced and GetValidators() method has been added. Specifically Page.Validate(ValidationGroupPropertyValue) and GetValidators(ValidationGroup) makes your life much easier

Focusing Controls

Validation Controls now have SetFocusOnError property to make the control focused in the case of an error. You can also use the Focus() method of server controls which will add client-side JavaScript to set focus to a particular control on page load

Browser compatibility

MS has used document.getElementById(id) in validation controls making client side validation possible in all the browser which supports JavaScript 1.2 or higher. This has make all the controls to be work in IE, Firefox and Opera.

Following are the Base Validation Control Properties from MSDN

ControlToValidate

The programmatic ID of the input control that the validation control will evaluate. If this is not a legitimate ID, an exception is thrown.

Display

The display behavior for the specified validation control. This property can be one of the following values:

None — The validation control is never displayed inline. Use this option when you want to show the error message only in a ValidationSummary control.

Static — The validation control displays an error message if validation fails. Space is allocated on the Web page for the error message even if the input control passes validation. The layout of the page does not change when the validation control displays its error message. Because the page layout is static, multiple validation controls for the same input control must occupy different physical locations on the page.

Dynamic — The validation control displays an error message if validation fails. Space for the error message is allocated dynamically on the page when validation fails. This allows multiple validation controls to share the same physical location on the page.

Note

Because space for the validation control is created dynamically, the physical layout of the page changes. To prevent the page layout from changing when a validation control becomes visible, the HTML element containing the validation control must be sized large enough to accommodate the maximum size of the validation control.

EnableClientScript

Indicates whether client-side validation is enabled. You can disable client-side validation on browsers that support this capability by setting the EnableClientScript property to false.

Enabled

Indicates whether the validation control is enabled. You can prevent the validation control from validating an input control by setting this property to false.

ErrorMessage

The error message to display in the ValidationSummary control if validation fails. If the Text property of the validation control is not set, this text is also displayed in the validation control when validation fails. The ErrorMessage property is commonly used to provide different messages for the validation control and the ValidationSummary control.

Note

This property does not convert special characters to HTML entities. For example, the less than character (<) is not converted to <. This allows you to imbed HTML elements, such as an <img> element, in this property’s value.

ForeColor

Specifies the color in which to display the inline message when validation fails.

IsValid

Indicates whether the input control specified by the ControlToValidate property is determined to be valid.

SetFocusOnError

Indicates whether focus is set to the control specified by the ControlToValidate property when validation fails.

Text

When set, this message is displayed in the validation control when validation fails. If this property is not set, the text specified in the ErrorMessage property is displayed in the control.

ValidationGroup

Specifies the name of the validation group to which this validation control belongs.