Hi moondaddy,
Thanks for posting in this group!!
Based on my understanding, you can not use your jscript function
"PaymentMenthod(this)" work with asp.net server control <asp:radiobutton>
===============================
I think you still do not quite understand the Asp.net web server control
model.
Asp.net server web control encapsulate the client side html, css and
javascript. And it will be execute at web server side. While for
Javascript(or JScript), it is a client side language, it will execute by
the IE, which view this page.
For <asp:radiobutton>, as a web server control, its OnCheckedChanged is a
server side event, you should specify a SERVER SIDE event handler to handle
this event. You specify a CLIENT SIDE JScript function for it, asp.net will
conside this function name as a server side function, but it can not find
one, so a runtime error is generated.
And why your change <asp:radiobutton> to <input type=radio>, then it works?
If you mark a html element with runat=server attribute, it will become a
server side html control.(Will execute at server side, then render to
client side). Please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
ml/cpconaspsyntaxforhtmlcontrols.asp
For Html control, any attribute it does not encapsulate will be added into
its Attribute collection(you can access it through "Attributes" property).
Please refer to:
http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconSharedHTMLControl
Properties.asp
For your radio control with "runat=server" attribute, it is mapping to
HtmlInputRadioButton class. HtmlInputRadioButton only encapsulate one
special server event; ServerChange, you did not handle it. So your
OnCheckedChanged will be treated as a client side event(handle by client
side JScript), and will be encapsulte into HtmlInputRadioButton.Attributes
collection. Then after rendering to client side, it will find the JScript
function "PaymentMenthod(this)", and it works.
I hope I have clarified all these things to you. If you want to use the Web
Server raidobutton control and want to add the client side event handler
for client side event OnCheckedChanged, you manually add the event handler,
like this:
<asp:radiobutton id="RadioButton1" runat="server" Text="Online Credit Card
Transaction:" Checked="True"></asp:radiobutton>
private void Page_Load(object sender, System.EventArgs e)
{
RadioButton1.Attributes.Add("OnCheckedChanged", "PaymentMenthod(this)");
}
====================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.