开发者

How to call JQuery CheckBox Changed Event inside a Jquery Accordion Header?

Thanks for all your valuable responses to the questions that I have asked before, those suggestions helped me a lot. I have one more question here. I am using a JQuery accordion control in my page,and the accordion header contains a checkbox, Based on the checkbox selection, I need to retrieve some date from the DB. So, I need the checkbox changed event to get fired, but The event never gets fired for some reason. I am building the checkboxes dynamically through code.

Code:

string sa= '';
sa+= '<h3><a href=#><input type=checkbox runat=server OnCheckedChanged=chkScores_CheckedChanged id=chkScorecard' + i + '>Auckland Aces</input></a></h3><div><p>';

after creating checkboxes like开发者_StackOverflow中文版 above, I am adding them to the accordion div.

If you observe, I am giving OnCheckedChanged event, but that event is not firing.

Any idea..Why it is happening like that. I have been trying for past 6 hours on this, but no luck.

Can you guys please tell me if I am doing anything wrong, or is there any alternate approach to this.

Thanks and appreciate your feedback.


you write
OnCheckedChanged=chkScores_CheckedChanged

covert it to

OnCheckedChanged="chkScores_CheckedChanged"

EDIT:

true, this will not work because it an html input and the event oncheckedchanged, and this event is for asp:CheckBox and at runtime it will covert to input html with

onclick="javascript:setTimeout('__doPostBack(\'checkBox1\',\'\')', 0)"

so, if you want, you can add onclick javascript function to the input and in this function call the server side,

Example using JQuery:

Insert input checkbox:

var htmlTags = '<input id="checkboxID" type="checkbox" runat="server"  onclick="CheckboxChange(this.id)" enableviewstate="true" />';

Add an Button to call it event:

<asp:Button ID="lbtnRefreshGV" runat="server" Text="" Height="0px" Width="0px" Style="visibility: hidden"  OnClick="lbtnRefreshGV_Click"></asp:Button>

Add javascript function

function CheckboxChange(id) {
        alert("In CheckboxChange");
        alert(id);
        $('#lbtnRefreshGV').trigger('click');
        alert("Out CheckboxChange");
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜