Personal Blog of Mustafa Basgun

Archive for the ‘Secure Coding’ Category

Best Practices for Speeding Up Your Web Site

leave a comment »

There are tones of programming practices that I have been doing while developing an online application without even knowing or thinking about the technical reasons behind them; such as placing stylesheets at the top between the head tags, preferring CSS sprites to create menu items, utilizing <link> instead of @import, putting or linking the heavy JavaScript code at the bottom, etc.. This list can easily get longer.

While googling a solution to fix an issue in one of my development projects, I just found a very useful article from Yahoo Developer Network which explains all the things that I mentioned above along with some other cool practices.

Click here to read it, and then print and bookmark it.

Written by Mustafa Basgun

February 12, 2009 at 6:04 AM

Utilize Read-Only TextBoxes in FileUpload Control of ASP.NET

with 9 comments

Nowadays, I am spending most of my work time on developing a “document depot” type of web application which has a heavy usage of FileUpload control. And, it was one of the requirements that users should not be able to modify the associated textbox after browsing the document from their hard drives. I believe it is a very good user-experience practice and it avoids some possible security issues as well. After walking around between some search results, I have found the following solution by assuming that FileUpload1 is the ID of the control:



As a result, users would be able to select a document only by using the Browse button.

I have tested the sample code with the latest versions of IE and Firefox, and everything seemed to be working fine with both browsers.

Written by Mustafa Basgun

January 28, 2008 at 5:00 PM

Rule The Back Button of A Browser by ASP.NET

with one comment

I recently needed to find a way to manage the back button of a browser for one of my applications at the work. I have found some forum entries and blog posts about the subject, but they were all some kind of complex solutions. All I wanted to do was just performing a single line code and redirecting to the main page when the user clicks the back button.

After spending couple of hours, here is the 4-step way that I came up with at the end.

First, assign an ID to the “body” tag in order to be able to call it in the Page_Load event:

Place a hidden HTML button control with an “onserverclick” event inside the page:

Add an “onunload” event (which will force a postback via Button1) to the “body” tag:

Finally, define the “onserverclick” event which was assigned to Button1 before:

Hope this helps!

Written by Mustafa Basgun

January 25, 2008 at 11:00 AM