Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  127] [ 3]  / answers: 1 / hits: 42527  / 11 Years ago, thu, march 28, 2013, 12:00:00

i am using bootstrap in my c# asp.net project and i want to show to show the modal popup from code behind.



in my page header i have a javascript function as follows:



function LoginFail() {
$('#windowTitleDialog').modal('show');
}


and on the click of my button i am calling the javascript as follows



ScriptManager.RegisterClientScriptBlock(this, typeof(System.Web.UI.Page), LoginFail, LoginFail();, true);


this does not show the modal popup. however, if i use something like alert('login failed'), it works fine.



can anybody please help with this?


More From » c#

 Answers
100

By default Bootstrap javascript files are included just before the closing body tag



    <script src=vendors/jquery-1.9.1.min.js></script>
<script src=bootstrap/js/bootstrap.min.js></script>
<script src=vendors/easypiechart/jquery.easy-pie-chart.js></script>
<script src=assets/scripts.js></script>
</body>


I took these javascript files into the head section right before the body tag and I wrote a small function to call the modal popup:



<script src=vendors/jquery-1.9.1.min.js></script>
<script src=bootstrap/js/bootstrap.min.js></script>
<script src=vendors/easypiechart/jquery.easy-pie-chart.js></script>
<script src=assets/scripts.js></script>

<script type=text/javascript>
function openModal() {
$('#myModal').modal('show');
}
</script>
</head>
<body>


then I could call the modal popup from code-behind with the following:



protected void lbEdit_Click(object sender, EventArgs e) {   
ScriptManager.RegisterStartupScript(this,this.GetType(),Pop, openModal();, true);
}

[#79265] Wednesday, March 27, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sandra

Total Points: 708
Total Questions: 100
Total Answers: 84

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
;