partial class DaveKehring : IProgrammer { }  RSS 2.0
# Monday, June 25, 2007

I often run into a situation where a user tries to click a Submit button more than once on a page when processing takes more than a few seconds. To remedy this, I created a very simple control based on the standard ASP.NET Button control (System.Web.UI.WebControls.Button). I created a new WebControl and inherit from System.Web.UI.WebControls.Button to retain all of the aspects of a standard button. Next, I override the AddAttributesToRender method and include the following code:


protected override void AddAttributesToRender(HtmlTextWriter writer)
{
    base.AddAttributesToRender(writer);
    writer.AddAttribute("onclick", "this.disabled=true;"
        + this.Page.ClientScript.GetPostBackEventReference(this, ""));
}


The first line calls the base classes implementation and then the second line adds a client-side event handler for the "onclick" event of the button. When the button is clicked, it is disabled and then a postback is initiated. This is important because if you just try to disabled the button, it will not be part of the postback and its server-side processing will not fire. That's why you need to include the postback callback function for the button that can be obtained from the call to ClientScript.GetPostBackEventReference.

Monday, June 25, 2007 8:09:56 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

# Wednesday, May 30, 2007

I was tring to create an ASP.NET website using Visual Studio.NET 2003 and got the following error that in part says:

"Unable to create web project ... The two need to map to the same server location".

I found so many threads about this with few answers. Here's how I solved my problem.

I was trying to create an ASP.NET website on one of my servers from Visual Studio.NET 2003 on my development machine. The problem was that the directory location of the "Default Web Site" node in IIS on the server did not map to the location where I was trying to create the new application based on the UNC path. For example, I was trying to create the application on the following path:

\\myserver\inetpub$\myapplication

This mapped to the physical location:

G:\Inetpub

... and translates to the URL

http://myserver/myapplication

In IIS on the server I looked at the "Default Web Site" node as this is where IIS will try to create the ASP.NET application because http://myserver translates to this location. Looking at the Home Directory tab at the Local Path parameter I noticed it was pointing to the physical location

C:\Inetpub\wwwroot

So, I simply changed this path to G:\Inetpub and it worked. So this is what the message means by "the two need to map to the same server location".

Don't forget of course that I had to create a UNC share with the appropriate permissions for this to work.

Hope this saves someone some time.

Wednesday, May 30, 2007 12:30:52 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

# Friday, March 30, 2007

I'm using VS.NET 2003, SQL Server 2000.

In my case, the error "internal connection fatal error" was being generated when using a DataReader to read the field values of a record. As I stepped through the code in the debugger I was also getting an "arithmetic overflow" error when calling GetDouble on a field. As I looked further it turns out this field in the database table for the given record had the value "-1.#IND". I'm not sure how that value got there but once I delete the record the error went away. So essentially the "internal connection fatal errror" exception was masking the root cause.

Friday, March 30, 2007 12:29:38 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
ASP.NET | SQL Server | VS.NET
Navigation
Archive
<June 2007>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dave Kehring
Sign In
Statistics
Total Posts: 11
This Year: 0
This Month: 0
This Week: 0
Comments: 2
Themes
Pick a theme:
All Content © 2012, Dave Kehring
DasBlog theme 'Business' created by Christoph De Baene (delarou)