Archive for the ‘.NET’ Category

KPI viewer Vista gadget development on Windows 2008 64Bit

November 18th, 2008 by koolb | No Comments | Filed in .NET, Business Intelligence, Programming, Sharepoint, Software Development, Vista, Windows

I wanted to display some KPIs as a vista gadget. I had to use the PC which I already setup SQL SERVER, MOSS and PPS on a Windows 2008 Server. I googled to find a way to setup Vista sidebar on Windows 2008 and found a great post from reggies blog with simple instructions. Sidebar worked like a charm on Windows 2008 after following the instructions on the reggies blog.
I also found a sample Vista gadget code from hanselman.com. Download and copy the code to gadget directory and add the gadget to the side bar. The method he has followed is to get the RSS feed from Sharepoint KPI List and setup the feed URL through the options dialog. After setting up the RSS feed the options dialog, it displayed the message “connecting” but nothing happened. I went through the Javascript code and couldn’t find any problem. Next, I setup the same gadget on a Vista Box and it worked without a problem.
I identified the problem is in the Windows 2008 and looked for a way to debug the code. Vista Gadgets cannot be debugged in a normal way and I found some good information from Keith Elder’s blog and howtogeek.com on setting up the debugging. When I debug, the problem was in the line where the XMLHttp.open ” g_XMLHttp.open(‘GET’, g_WsUrl + “&kalle=1234″, true);” and it was throwing an exception saying “Microsoft JavaScript runtime error: Permission denied”. But everything was fine on IE and there cannot be a problem with JavaScript engine. so I looked google for a solution. Couldn’t find the exact solution but some one has resolve the issue by coping vista gadget files to a FAT partition and coping them back to NTFS partition. I understood that the issue is not in the JavaScript but with file permissions. When I right click on the files and I got the following dialog.

Windows File Properties - UnBlock Button

I saw something different as there is a Unblock button. I pressed the Unlock button for the all the files related to Vista gadget and retried again. This time it work with out a problem. This is the first time I have come across the “Unblock” button scenario. I found some information on the “Unblock” functionality after some searching. If you get “Microsoft JavaScript run time error: Permission denied” again, don’t forget to check file permissions first, specially on Windows 2008 and Visa.

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.