"ASP:" WebControls and Non-JavaScrip

A

Alex Maghen

Hi. I'm confused about something: I love using the <asp:...> WebControls and
they work amazingly in IE, etc. But my problem is, let's say I've created a
page and it has things like asp:LinkButtons and asp:Buttons, etc. but the
browser doesn't support JavaScript (or, as really seems to be the problem, it
*says* it supports JavaScript but doesn't somehow). Is there a way that I can
designate those controls (or, in fact, the whole Page) NOT to use JavaScript
but, instead, to do QueryString or Form stuff in the background???

Alex
 
A

Alex Maghen

Well they do for me. Example: I create a form in an ASPX page, stick an
asp:Button in there with an onClick="SomeFunction". If I do NOTHING else,
when I point at that button in the browser, the Status Bar shows that it'll
be doing some JavaScript to get me where I'm going. Am I doing something
wrong here???
 
A

Anthony Williams

Uh - take a look at the generated HTML from an ASP.NET page for LinkButtons:

javascript:__doPostBack('ldContent$_ctl1$uclSupplierEditor$dgSupplierContacts$_ctl2$lbtnEdit','')

Anything that doesn't ordinarily incur a postback calls javascript to force
the form to postback.
 
S

Scott M.

Yes, but this is YOU adding JavaScript to the control, not the control
having this automatically. And, with all JavaScript that you add, you run
the risk of it running (or trying to run) in a browser that doesn't support
it. It's not up to VS.NET to prevent YOU from squeezing JavaScript into the
rendered output.

What you may want to do is stop adding the client-side event handlers
manually and add them programmatically instead only if the client supports
JavaScript.

You could check the ServerVariables collection to see what kind of client
you are serving and then if it is a client that supports JavaScript, you
could add something like:

btnTest.attributes.add("onClick","SomeFunction")

-Scott
 
S

Scott M.

Ok, but the OP also asked about asp:button controls, which do not render
with JavaScript. Not to mention that the OP was referring to JavaScript of
his own, not the JS added by VS.NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top