Question:You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You plan to create a Web form to validate credit card information.
You write the following code fragment for the Web form.
<script type="text/javascript">
function validateCreditCard() {
var creditCard = $get('txtCreditCard').value;
PageMethods.ValidateCreditCard(creditCard, onValidateCreditCardComplete); }
function onValidateCreditCardComplete(result) { if (!result) {
alert('Credit card number is not valid.');
document.getElementById('txtCreditCard').focus(); } }
</script>
<asp:ScriptManager runat="server" ID="ScriptManager1" EnablePageMethods="true" />
<asp:TextBox runat="server" ID="txtCreditCard" onblur="javascript:validateCreditCard();" />
You need to implement the ValidateCreditCard method in the code-behind page class that validates the credit card number.
Which code segment should you use?
A [ScriptMethod()]
public static bool ValidateCreditCard(string ccNumber) {
bool isValid = CreditCardAuthority.ValidateCard(ccNumber);
return isValid; }
B [ScriptMethod()]
public bool ValidateCreditCard(string ccNumber) {
bool isValid = CreditCardAuthority.ValidateCard(ccNumber);
return isValid; }
C [WebMethod()]
public bool ValidateCreditCard(string ccNumber) {
bool isValid = CreditCardAuthority.ValidateCard(ccNumber);
return isValid; }
D [WebMethod()]
public static bool ValidateCreditCard(string ccNumber) {
bool isValid = CreditCardAuthority.ValidateCard(ccNumber);
return isValid; }