Archive for the ‘ASP.NET’ Category

Javascript Alert Message

Wednesday, March 19th, 2008

How to show javascript alert message from code behind? You probably know, we can do it like this:
ClientScript.RegisterStartupScript(Page, “message”, “alert(’Hellow world!’);”, true).

However this method is not going to work in AJAX environment. For AJAX you need to use: ScriptManager.RegisterStartupScript.

Here is a little utility method, which displays javascript alert message both in AJAX environment and on regular page:
(more…)

Server side thumbnail generation

Saturday, March 15th, 2008

I was creating virtual tour page for one of our new projects and I faced a problem of creating thumbnails on a fly. Usually

image galleries are done in flash and we (asp.net developers) doesn’t face this problem, however this project had requirement that was easier to implement with asp.net.

Below is the code for ImageThumbnail.aspx.cs, which does server side resizing:
(more…)

Regular Expression for adding RequiredFieldValidators

Thursday, March 6th, 2008

Here is the quick way of adding RequiredFieldValidator for a big form.

In aspx file do Quick Replace with Reqularexpressions turned on

Find what: ID=\”{txt{[^\”]*}}”

Replace with: ID=\1 runat=”server”></asp:TextBox><asp:RequiredFieldValidator ID=”val\2″ runat=”server” ControlToValidate=”\1″ ValidationGroup=”ChangeAddress” Text=”*”></asp:RequiredFieldValidator>

Do “Replace” for fields that need validation.