How to Calling a Javascript function from c# code
Calling a Javascript function from c# code:
Hello friend one day I was trying to call a javascript
function which will open the aspx child page from c# code behind. I tried using
a literal control and assigned its text property the script funciton call.
litAlert.Text = "<script>callKeywords('" +
Name + "','Keyword',+'Region');</script>";
Where little Alert is
the literal control. It works fine with a normal alert,
but not sure what is
the problem with this?
The JavaScript function is as given below:
Function call_Keywords(textid, Keywords, KeywordValue)
{
var url="Keywords.aspx?textvalue="+ textid
+"&KeywordList="+Keywords+"&KeywordName="+KeywordValue;
var Parameters="location=0,toolbar=0,width=375,height=250,position=aboslute,
scrollbars=0,resizable=0";window.open(url,"School",parameters);
}
Some time we use fallowing option to call C# code by java
script by this
ScriptManager.RegisterStartupScript(this, this.GetType(),
"starScript","callKeywords('" + Name +
"','Keyword',+'Region');", true);
If you want to call java script code on C# code:
If you don't have the
scriptManager you can use this:
Page.RegisterStartupScript("starScript", "callKeywords('"
+ Name + "','Keyword',+'Region');");
Asp.net Related Other Post:
- What is ASP.net Programming Part 2,Chat web application in asp.net programming
- Sql Query for asp.net Programming ,How to get Server IP, How to create graph in asp.net:
Thanks for sharing such an interesting blog.
ReplyDeleteJava course in Pune