hi
How to put ScrollPositionOnPostback for bootstrap modal popup
I use modal on page below are codes:
<script type="text/javascript">
$(function () {
$("#Contact").click(function () {
$('#myModal1').modal('show');
});
});
</script>
<div class="modal fade" id="myModal1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div id="btnclose">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div id="topadd2M">
<div id="DNCRM1">
<asp:textbox id="Txtname" runat="server" cssclass="txtnameCM" tabindex="1"></asp:textbox>
</div>
<div id="DNCRM1">
<asp:textbox id="Txtmobile" runat="server" cssclass="txtmobCM" tabindex="2"></asp:textbox>
</div>
<div id="DnameC7M">
<div id="message" class="attenCCM">
<asp:label id="Label53" runat="server" cssclass="lblattenC1M">Please insert data correctly </asp:label>
</div>
<asp:requiredfieldvalidator display="Dynamic" id="RequiredFieldValidator1" runat="server" controltovalidate="Txtname"></asp:requiredfieldvalidator>
<asp:requiredfieldvalidator display="Dynamic" id="RequiredFieldValidator2" runat="server" controltovalidate="Txtmobile"></asp:requiredfieldvalidator>
<script type="text/javascript">
function WebForm_OnSubmit() {
var message = document.getElementById("message");
message.style.display = "none";
if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) {
for (var i in Page_Validators) {
try {
if (!Page_Validators[i].isvalid) {
message.style.display = "block";
// Reopen modal.
$('#myModal1').modal('show');
}
} catch (e) {
}
} return false;
} return true;
}
</script>
here I use validation for textboxes and I use this code for the page:
MaintainScrollPositionOnPostback="true"
Now here in Modal when I don't insert data and click on the button it will show a message that I should insert data problem is that when I click a button it refreshes the page and goes to the top of Modal I should scroll down until I can see the message
What should I do?
Best regards
Neda