使用javascript访问隐藏字段值 [英] Access hidden field value using javascript

查看:67
本文介绍了使用javascript访问隐藏字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

谁能告诉我,我怎样才能使用javascript获取隐藏字段的价值。



这是aspx代码



Hello Friends,
Can anyone tell me, how I can get the value of hidden field using javascript.

Here is aspx code

<asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete" CssClass="delbutton" CommandArgument='<%#Eval("noticeid") %>'>Delete
<asp:HiddenField ID="hfID" Value='<%#Eval("noticeid") %>' runat="server" />





这里我在尝试什么,我对隐藏领域具有约束力。使用这个值我将使用Json删除记录。



我试过以下JavaScript





Here what I'm trying, I'm binding value to hidden field. Using this value I'm going to delete record using Json.

I tried following JavaScript

function funDelete() {
            alert("Start");
            if (confirm("Do you want to delete this record?")) {
                alert("Step 1");
                try {
                    $(document).ready(function() {
                        $('#lnkDelete').click(function() {
                            alert("Ready");
                        });
                        
                    });
                    //GET ID OF RECORD TO BE DELETED
                    var id = document.getElementById('<% =hfID.ClientID %>').value;
                    //$('#hfID').val();
                    
                    alert("ID:" + id);
                    $.ajax({
                        type: "POST",
                        url: "QCNotice.aspx/deleteComment",
                        data: "{'args':'" + id + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function() {
                            alert("IN");
                            row.css("background-color", "Red");
                            row.fadeOut(500, function() {
                                row.remove();
                            });
                        },
                        error: function(event, request, settings) {
                            alert("Ajax Error");
                        }
                    });
                }
                catch (e) {
                    alert("Error:" + e.message);
                }
            }
            return false;
        }





错误说:重载解析失败,因为没有可访问的'Write'可以用这些参数调用



任何想法,我哪里出错?



提前致谢



It gives error saying: Overload resolution failed because no accessible 'Write' can be called with these arguments

Any idea, where I'm going wrong??

Thanks in advance

推荐答案

(document).ready(function(){
(document).ready(function() {


('#lnkDelete' ).click(function(){
alert(Ready);
});

});
//要删除的记录的GET ID
var id = document.getElementById('<%= hfID.ClientID%>')。value;
//
('#lnkDelete').click(function() { alert("Ready"); }); }); //GET ID OF RECORD TO BE DELETED var id = document.getElementById('<% =hfID.ClientID %>').value; //


('#hfID')。val();

alert(ID:+ id);
('#hfID').val(); alert("ID:" + id);


这篇关于使用javascript访问隐藏字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆