Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact


ASP.NET 2.0: Place JavaScript inside the Page.Header

The Page.ClientScript object allows you to place JavaScript inside the Page, but it's limited in the fact that you cannot use it to place JavaScript inside the Head tags of the Page. But fortunately there is a way to do this. Add a .js file include inside the page header: [code:c#] HtmlGenericControl Include = new HtmlGenericControl("script"); Include.Attributes.Add("type", "text/javascript"); Include.Attributes.Add("src", ""); this.Page.H... [More]

JavaScript: Loop through all elements in a form

Since I've been doing alot of JavaScript programming lately, I figured I could start blogging some code snippets. Here is a JavaScript snippet that shows how to loop through all the elements in a form and retrieve their element type, name and values. I had to use this code to gather all form values so I could post them to the server using AJAX. <html> <head> <script type="text/javascript"> function DisplayFormValues() { var str = ''; var elem = document.... [More]