asp.net how to save checkbox satus when the update panel works?

十年热恋 提交于 2019-12-11 08:58:10

问题


I have an update panel witch works in timer every 30 seconds.

the page contains many checkbox. when the update panel works, the check boxes return to their default statuses though some of them were selected before the update panel works.

any help please? There are the checkboxs:

<div ID="campaignDiv" runat="server" >
                            <ul>
                                <li>
                                    <span class="textDropdown">Text1</span>
                                    <input type="checkbox" id="1" value="1"/>
                                    <label for="1"></label>
                                </li>
                                 <li>
                                     <span class="textDropdown">Text1</span>
                                    <input type="checkbox" id="2" value="2"/>
                                    <label for="2"></label>
                                </li>
                                 <li>
                                     <span class="textDropdown">Text1</span>
                                    <input type="checkbox" id="3" value="3"/>
                                    <label for="3"></label>
                                </li>
                                 <li>
                                     <span class="textDropdown">Text1</span>
                                    <input type="checkbox" id="4" value="4"/>
                                    <label for="4"></label>
                                </li>
                            </ul>
                        </div>

回答1:


Add attribute runat="server" to your checkboxes. This will make them server-side controls and allow to use ASP.NET ViewState to save their states.

Note that you may have to change IDs of the checkboxes (and related for labels) currently yours are numeric like "1", you will have to make them alphanumeric e.g. "C1".



来源:https://stackoverflow.com/questions/23848875/asp-net-how-to-save-checkbox-satus-when-the-update-panel-works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!