DKR DKR - 8 months ago 52
ASP.NET (C#) Question

how to set text of <h4> from c# in

I have a popup created in bootstrap in my .aspx page.

<div id="myModal" class="modal fade " tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">

<div class="modal-title">
<h4 id="modaltext" runat="server" class="modal-body"></h4>

<div class="modal-footer">
<button type="button" data-dismiss="modal" onclick="show_loginpanel()" class="btn btn-primary">Okay</button>

In c# .cs file,

modaltext.InnerHtml = "Successful";

From c#, i cam calling a js function which shows above modal popup.

ScriptManager.RegisterStartupScript(this, GetType(), "Message", "showModal();", true);

JavaScript Function: showModal()

function showModal() {



When I run my project, On popup there is no text displayed. tag is empty.

Can someone tell me what I am missing.



Use LiteralControl for things like this:

<h4><asp:Literal id="SuccessfulLine" runat=server /></h4>

Code behind:

SuccessfulLine.Text ="Successful";


You can achieve that with javascript too:

string successfullString = "Successful";
string js = @"$( document ).ready(function() {

     $('#modaltext').text('" + successfullString + "'@

ScriptManager.RegisterStartupScript(this, GetType(), "Message", js , true);