error in passing value from cs to jquery

Posted by Klbaiju under jQuery on 3/22/2016 | Points: 10 | Views : 316 | Status : [Member] | Replies : 1
Hi,

I want to pass value from cs file to jquery file

following is working code

cs file

 protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
Heading="Baiju";
}
}

public string Heading { get; set; }

jquery file

$(document).ready(function () {
var title = "<%=Heading%>";
alert(title);

});


this is working fine and alert message is Baiju

problem is if i remove jquery file and write the code in another js file and call it in the page

like

<script type="text/javascript" language="javascript"  src="bd.js">


it will not work

then alertmessage will be

"<%=Heading%>";



How to solve this


Regards

Baiju




Responses

Posted by: Bhuvanesh6 on: 7/25/2016 [Member] Starter | Points: 25

Up
0
Down
Better load the Jquery file at end of the page.

Assign the value of header to a global variable of Jquery and use that value in alert.

Try and let me know.

Use the [F12] key to view developer tools option and view console tab and check any error is shown, share that error also with screen shot, if that not works.

Bhuvan

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response