0

In my gridview header, i have user names and what I need is to display user details, in bootstrap popover when user click on the user name.

I tried below just to check if can get the popover to display from code behind but it did not work:

ASPX:

<a href="#" id="popover">the popover link</a>
<div id="popover-head" class="hide">
    some title
    <button type="button" class="close" data-dismiss="popover" aria-hidden="true">×</button>
</div>
<div id="popover-content" class="hide">
    <input type="text" id="txtInput" />
    <button type="button" id="btn" class="clickme" value="Calc" ></button>    
</div>

Code behind:

Protected Sub I1_Click(sender As Object, e As System.EventArgs) Handles I1.Click
        Dim sb As New System.Text.StringBuilder
        sb.Append("<script type='text/javascript'>")
        sb.Append("$('#popover').popover({")
        sb.Append("html: true,")
        sb.Append("title: function () {")
        sb.Append("return $(""#popover-head"").html();")
        sb.Append("},")
        sb.Append("content: function () {")
        sb.Append("return $(""#popover-content"").html();")
        sb.Append("}});")
        sb.Append("</script>")
        ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(),
            "popoverscript", sb.ToString(), False)
    End Sub

How can I call a popover from the code behind or any alternatives? Help please...

Thanks, Navin

user2269971
  • 49
  • 1
  • 1
  • 7

1 Answers1

1

you are looking at the wrong part of scriptmanager.

Use ScriptManager.RegisterStartupScript instead of ScriptManager.RegisterClientScriptBlock

user2930100
  • 346
  • 4
  • 10
  • Yup. this opens the popover but popover closes as soon as it opens. – user2269971 Jan 15 '14 at 06:40
  • looks like something else is closing the popover. try adding another line in the javascript: sb.Append("$('#popover').popover('show');") before you close the script tag – user2930100 Jan 16 '14 at 21:50