.ashx内部读取和设置html元件的内容

一、读取和设置html内部元件的值

HTML:
<input id="_isExistBilling" type="hidden" value="" />
<input id="_paymentOrderId" type="hidden" value="" />

//给客户端赋值
Document.Find("#_isExistBilling").First().SetAttribute("value", ViewData["IsEnable"].ConvertTo<bool>().ToString());
Document.Find("#_paymentOrderId").First().SetAttribute("value", paymentOrderId.ToString());
fp_paymentMethod.Find("#continue_pay").First().SetAttribute("href", Url.Action("Pay", "Payment", new { paymentOrderId = paymentOrderId }));


二、查找HTML内部元素值

HTML:
<div id="fp_paymentMethod" class="Payment_Con_main w678">
    <ul class="Payment_Method">
        <!--Paypal credit card-->
        <li>
            <label class="visa00 fleft mr20" for="paymentMethod_paypalguestchekout"></label>
            <div class="ws506 ml130">
                <label class="f12 c000" for="paymentMethod_paypalguestchekout">
                    <input id="paymentMethod_paypalguestchekout" name="paymentMethod" type="radio" value="PaypalGuestCheckout" />
                    <span id="Paypalguestchekout_Title"></span>
                </label>
                <p class="f11 c666 lh14 m10 pl10">When you click continue, you will be redirected to the Paypal site to pay with your credit card <span class="orange">as a Paypal guest</span>.</p>
                <p class="f11 c666 lh14 m10 pl10">Payment Types:</p>
                <div class="visaicon"></div>
            </div>
            <div class="clear"></div>
        </li>
        <!--Paypal-->
        <li>
            <label class="paypal00 fleft mr20" for="paymentMethod_paypal"></label>
            <div class="fright ws506">
                <label class="f12 c000" for="paymentMethod_paypal">
                    <input id="paymentMethod_paypal" name="paymentMethod" type="radio" value="PaypalCheckout" />
                    <span id="PaypalCheckout_Title"></span>
                </label>
                <p id="PaypalCheckout_Description" class="f11 c666 lh14 m10 pl10">
                    When you click continue, you will be temporarily redirected to the Paypal site to log in and complete your order.
                </p>
            </div>
            <div class="clear"></div>
        </li>

        <!--GB-->
        <li>
            <label class="visa00 fleft mr20" for="paymentMethod_gb"></label>
            <div class="ws506 ml130">
                <label class="f12 c000" for="paymentMethod_gb">
                    <input id="paymentMethod_gb" name="paymentMethod" type="radio" value="GlobeBill" />
                    <span id="GlobeBill_Title"></span>
                </label>
                <p id="GlobeBill_Description" class="f11 c666 lh14 m10 pl10">Payment Types:</p>
                <div class="visaicon width112"></div>
            </div>
            <div class="clear"></div>
        </li>
        <!--Webmoney-->
        <li>
            <label class="webmoney00 fleft mr20" for="paymentMethod_webmoney"></label>
            <div class="fright ws506">
                <label class="f12 c000" for="paymentMethod_webmoney">
                    <input id="paymentMethod_webmoney" name="paymentMethod" type="radio" value="Webmoney" />
                    <span id="Webmoney_Title"></span>
                </label>
                <p id="Webmoney_Description" class="f11 c666 lh14 m10 pl10">WebMoney is available in all countries and supports currencies RUB,USD,EUR.</p>
            </div>
            <div class="clear"></div>
        </li>

    </ul>
    <div id="paymentMethod_tips" class="hide">Please choose a payment method.</div>
    <a id="continue_pay" href="javascript:void(0);" οnclick="_continue(this);" class="conSaveShipAdress fright"></a>
</div>

ashx代码:
--获取html内部元素的值     
var fp_paymentMethod = Document.Find("#fp_paymentMethod").First();
fp_paymentMethod.Find("ul li").ToArray().ForAll(li =>
{
    string paymentMethodValue = li.Find("input[name=paymentMethod]").First().Attribute("value").AttributeValue;
    if (!paymentRequest.CandidatePaymentMethods.IsNullOrEmpty())
    {
        if (!paymentRequest.CandidatePaymentMethods.Contains(paymentMethodValue, StringComparer.OrdinalIgnoreCase))
        {
            li.Remove();
            return;
        }
    }
    //如果语种是俄罗斯语,去掉WebMoney支付方式
    if (paymentRequest.LanguageCode.ToUpper() == "RU" && paymentMethodValue.ToLower() == "webmoney")
    {
        li.Remove();
        return;
    }
});
           






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值