I have one problem in ASP.NET 2.0. (I'm a beginner in ASP.Net. )
I want to control radio checked_changed event using VBScript.
I already try this code in button click using script and its worked well but when I move to radio button, its not working.
anybody know the reason and why???? (And I don't want to use 'AutoPostBack = true' because it post back to server every time i click on it. so the page seems to refresh every time i click. i don't want it to reload or refresh or flash the screen. just like windows based app to let it works smooth.)
sorry to disturb you guys if my question is too simple.
Here is my script code:
Code:
Protected Sub CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Me.TextBox1.Text = "Click on script"
Me.TextBox1.Enabled = False
End Sub
Web Dev is not like Win Dev. Web Dev require you to set the AutoPostBack Property to TRUE.
If you do not wish to refresh the page everytime you change the option, you can look into the AJAX way of accomplishing the same effect. Albeit, the page is still refreshed but to the end user it would look like the page didn't refresh at all.
Or if your requirement is not too complex, the effect could be achieved using simple JS trick.
Look around on google and here for numerous such examples.
Web Dev is not like Win Dev. Web Dev require you to set the............Or if your requirement is not too complex, the effect could be achieved using simple JS trick.
Look around on google and here for numerous such examples.
Thanks Harsh Gupta!
I also try googling but still no results for me (May be my english grammer skill is not good)
and for AJAX, I think i still need more to get to that kind of level
Anyway, Thanks
I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.
Thanks mendhak.
It working well with your code.
But my problem is actually i want to hide a text box.
I have something like:
Leave Reason: Sick (Radio button)
Personal (Radio button)
Annual (Radio button)
Other (Please Specify) (Radio button) (Here comes the textbox)
So, my logic is <when user click on any first 3 radio buttons, textbox will invisible. if user choose Other, textbox will appear.>
I try set value to document.getElementById(txtID).visible = false;
Its not working. And so i tried googling and found this... document.getElementById(txtID).style.visibility='hidden';
So, in anyway, i seems to manage the requirements. I attached my code with this post, can anyone please check whether it is in correct format of using code & script???? (Sorry for this, i know u r not corrector for me ) Thanks.
I think i still need to learn a lot.
N Thanks mendhak.
I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.
Yes, style.visibility will help you hide that textbox using client side scripting.
No, your script won't work because RadioButton1 might have a different ID at runtime. So you'll want to pass that along to the function as well or make it a 'global' javascript variable. It'd be easier to show you the pass-it-along rather than confuse you with extra 'methods'.
Yes, style.visibility will help you hide that textbox using client side scripting.
No, your script won't work because RadioButton1 might have a different ID at runtime. So you'll want to pass that along to the function as well or make it a 'global' javascript variable. It'd be easier to show you the pass-it-along rather than confuse you with extra 'methods'.