code snippet

Include javascript programmatically using ASP.NET 2.0

The thing is I want to include javascript into the page programmatically mainly because I want to use the full url for the source of the javascript.

So I put these on the code behind during the OnLoad event.

int i = 1;
HtmlGenericControl script = new HtmlGenericControl("script");
script.Attributes.Add("type","text/javascript");
script.Attributes.Add("src",Page.ResolveUrl("~/your url"));
//add after the title tag
Page.Header.AddAt(i++,script);

Tags:

Thursday, September 27th, 2007 code snippet, programming No Comments

Generating random number and send to user’s email

Someone asked me about this, here i thought to share with you all. The code is not the perfect, but important thing is the logic behind it.

You can find the snippet below. The logic is like a maybank2u transaction. You request the code, put it in the database with the user id, and send the random number to user’s email. After that, when the user upload the file, with the code, you check the database. that one in another script after you send the file to upload.

You need to have your php server configured with mail function, else it won’t work.

Code Snippet

Tags:

Wednesday, April 18th, 2007 code snippet, programming No Comments

Search

 

My Flickr

DSC_3950P4054890P4054887