You shouldn't rely on Javascript for critical functionality if you
think the user will have it disabled, JS should add to the experience
but not prevent the user from using your site if they don't have it
enabled(depending on your way of thinking).
Look at some big AJAX-enabled sites for example, they should fall back
to the standard postback model if JS is disabled.
-Jamie
Crazy
This got left unanswered, and it's a VFAQ, so I'll add my comments :
Let's say we have a .aspx page with the following form tag : (Line
nos. are for reference)
1. <form id="Form1" runat="server">
2. ..
3. ..
4. ..
5. </form>
Now let's look at key differences for each method :
A.
Page.RegisterClientScriptBlock() will insert the *block* of script
before Line 2.
Page.RegisterStartupScript() will insert the script after Line 4.
B.
Page.RegisterClientScriptBlock() should usually be used for scripts
encapsulated in functions. (hence the word "block")
Page.RegisterStartupScript() can be used for any script, even if it's
not in a function.
C.
Page.RegisterClientScriptBlock() should be used for functions that
don't need to run on Page load.
Page.RegisterStartupScript() should be used for scripts that must run
on Page Load.
D.
Page.RegisterClientScriptBlock() should be used for a script that does
not require the form elements to have been created.
Page.RegisterStartupScript() should be used for scripts that require
the form elements to have been created and uses references to them.
Notice that all the 4 differences are essentially related to each
other (they build upon the prev. one). The difference put in one line
can sometimes be too subtle, so I separated it out...
Disclaimer : This is written from my own experience on their usage and
I was initially quite confused about them too, so if I'm mistaken,
someone please correct me.
Raghu
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This e-mail (and any attachments) are confidential and intended solely for the use of the individual or entity to whom they are addressed. While we take every reasonable precaution to screen out computer viruses from emails, including sweeping this message by MIME Sweeper version 5.2, attachments to this email may contain such viruses. We cannot accept liability for loss or damage resulting from such viruses. The integrity of email across the Internet cannot be guaranteed and Financial Objects plc will not accept liability for any claims arising as a result of the use of this medium for transmissions by or to Financial Objects. It may contain personal views which are not the views of Financial Objects unless specifically stated. If you have received it in error, please delete it from your system, do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that Financial Objects monitors e-mails sent and received. If you have received this email in error please notify Financial Objects plc. Contact details can be found on our website. World Wide Web: http://www.finobj.com.
Information: Financial Objects plc is a public company, registered in England and Wales, registered number 03268748, registered office: 45 Monmouth Street, Covent Garden, London, WC2H 9DG.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
Well, as the page loads, it's elements are created in sequence as you
declare them. So, if you have a script that refers to an element
before it has been created in the Object model of the page, an error
will result. This is why RegisterStartupScript is declared at the end
of the form tag (all form elements have been created and can be
accessed).
Hope that helps. ;-)
On Jun 28, 8:01 pm, crazy <crazysan...@gmail.com> wrote:
> sorry .. no problem
>