Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
Disabling button fires Postback on click ASP.NET 2.0
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
pahluwalia
17y
2.8k
1
Reply
This is a very weird problem that I am facing. I have a button with required field validator for a textbox. And all I do in Page_Load is to disable that button and enable it when something in textbox is entered. The problem is everytime I click the button, even if the textbox is empty, it fires a postback.
If I dont disable the button in page load, it works fine.
Any help will be greatly appreciated.
Here is
Page_Load
:
btn.Enabled =
false
;
text1.Attributes.Add(
"onchange"
,
"document.form1.btn.disabled=false;"
);
And this is the
aspx page
:
<
form
id
="form1"
runat
="server">
<
asp
:
ValidationSummary
ID
="vsImportExclusions"
runat
="server"
ValidationGroup
="import"
/>
<
asp
:
TextBox
ID
="text1"
runat
="server"></
asp
:
TextBox
>
<
asp
:
RequiredFieldValidator
ID
="rtext1"
ControlToValidate
="text1"
runat
="server"
ErrorMessage
="ERROR"
ValidationGroup
="import"
Display
="None"></
asp
:
RequiredFieldValidator
>
<
asp
:
Button
ID
="btn"
Text
="OK"
runat
="server"
ValidationGroup
="import"
/>
</
form
>
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
login form
compare database value