本文介绍了在C#代码后面显示页面加载div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi i need help in c# code,Eg : I have 3 div on screen, Each contains controls for area code ,country code,Phone number and desc. I want no of div to be rendered registered with application. Let say if i have registered 2 phone numbers with area code and desc then on page load i need to show 2 div sections to shoe two contact details on the screen similar if user has registered 3 phone numbers then there should be 3 div sections should be rendered also max limit of contact no registered is 3.
我尝试过:
What I have tried:
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="jumbotron">
<div id="section1" class="phoneDetails">
<label>
<input type="checkbox" id="check1" value="1" /></label>
<input type="text" name="Phone1" value="" />
<input type="text" name="value" value="" />
</div>
<div id="section2" class="phoneDetails">
<label>
<input type="checkbox" id="check2" value="1" /></label>
<input type="text" name="Phone1" value="" />
<input type="text" name="value" value="" />
</div>
<div id="section3" class="phoneDetails">
<label>
<input type="checkbox" id="check3" value="1" /></label>
<input type="text" name="Phone1" value="" />
<input type="text" name="value" value="" />
</div>
<div id="section4" class="phoneDetails" style="display:none">
<label>
<input type="checkbox" id="check4" value="1" /></label>
<input type="text" name="Phone1" value="" />
<input type="text" name="value" value="" />
</div>
<div id="button">
<input id="btnAdd" type="button" value="+">
<input id="btnRemove" type="button" value="-">
</div>
</div>
<script>
debugger;
$(document).ready(function () {
var sections = [];
$('[id^="section"]').each(function () {
sections = this;
});
});
$("#btnAdd").click(function () {
alert($('[id^="section"]:visible').length);
$('#section2').insertAfter($('[id^="section"]:visible:last'));
});
$("#btnRemove").click(function () {
$('input:checkbox[id^="check"]:checked').each(function () {
$(this).closest('div').remove();
});
});
</script>
</asp:Content>
推荐答案
这篇关于在C#代码后面显示页面加载div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!