Disable entire asp.net form (using vb.net)

C

Chris

I have an asp.net page say page1.aspx. The form in html code is <form
id = "Form1">
And i want to disable all the fields of the form after some code steps.
I had created a javascript funct:

function disable()
{
alert("Forms length is :" + Form1.length);
for (i = 0; i < Form1.length; i++) {
var formElement = Form1.elements;
if (true) {
formElement.disabled = true;
}
}
}

And it can be invoked in events like 'onClick'..

As i need to call it from my asp.net code, I can use
button1.attributes.add("onClick","disable()")

But i dont want to call it on event, in fact i want my page to do some
steps and then on some condition, disable it.

Ne other suggestions are also welcomed!!

TIA,
 
K

Kevin Frey

You want your page to "do some steps" and then on some condition, disable
it...

Is the "do some steps" stuff when the page loads? In which case you can tie
the "do some steps" code to the body.onload event, and have it call
disable( ) if need be.

Does that help?

Kevin
 
C

Chris

Thnx Kevin,
Yep, its in the page load event. It fetches some values, and then later
on on some specific condition, may have to disable the form.

How do i call this disable function ? Its a javascript function.

Thnx..

Kevin said:
You want your page to "do some steps" and then on some condition, disable
it...

Is the "do some steps" stuff when the page loads? In which case you can tie
the "do some steps" code to the body.onload event, and have it call
disable( ) if need be.

Does that help?

Kevin

Chris said:
I have an asp.net page say page1.aspx. The form in html code is <form
id = "Form1">
And i want to disable all the fields of the form after some code steps.
I had created a javascript funct:

function disable()
{
alert("Forms length is :" + Form1.length);
for (i = 0; i < Form1.length; i++) {
var formElement = Form1.elements;
if (true) {
formElement.disabled = true;
}
}
}

And it can be invoked in events like 'onClick'..

As i need to call it from my asp.net code, I can use
button1.attributes.add("onClick","disable()")

But i dont want to call it on event, in fact i want my page to do some
steps and then on some condition, disable it.

Ne other suggestions are also welcomed!!

TIA,
 
C

Chris

...And in the function 'Form1' is the html form. So when i try to use it
in 'RegisterStartupScript' , its not recognised.

How can i access the function in html, from asp.net (using vb.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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top