c# to javascript
i have javascript function and i want to write some text in that function fron c# backend.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
samantaPosted Dec 23, 2014, 11:13 PM
thanks for your help.
this is my c# code
private void BindInitalView()
{
try
{
SqlCommand objCommand = new SqlCommand();
objCommand.CommandText = "SELECT [prd_ID] ,[img_ID],[img_X],[img_Y],[img_Thumb],img_Description,img_Title" +
" FROM [test].[dbo].[tblProductImage]";
objCommand.CommandType = CommandType.Text;
objCommand.Connection = _databaseConnection;
SqlDataReader objRs = objCommand.ExecuteReader();
while (objRs.Read())
{
string imageTagId = objRs["img_ID"].ToString();
string title = objRs["img_Title"].ToString();
string description = objRs["img_Description"].ToString();
string pointX = objRs["img_X"].ToString();
string pointY = objRs["img_Y"].ToString();
// how can i add this line inside javascript functon
"imageTagsObj.addImageTag('" + imageTagId + "','" + title + "','" + description + "','" + pointX + "','" + pointY + "'); \n";
}
objCommand.Dispose();
}
catch( Exception ex){
}
my javascript function
function setImageTags() {
//imageTagsObj.addImageTag(imageTagId, title, "", description, pointX, pointY, 0, 0, false, false);
}
Manish Kumar ChoudharyPosted Dec 23, 2014, 11:04 PM
You Can use Web Method and Ajax
}
samantaPosted Dec 23, 2014, 10:58 PM
Manish Kumar ChoudharyPosted Dec 23, 2014, 10:53 PM
Hi samanta,
Go through following links it might help you
http://www.codeproject.com/Tips/421207/Accessing-Csharp-Variables-in-JavaScript
http://stackoverflow.com/questions/9458494/access-c-sharp-variable-from-javascript