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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Dec 23, 2014, 5:53 PM EST
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
samantaRank #3,157 · 454 reputationPosted Dec 23, 2014, 5:58 PM EST
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Dec 23, 2014, 6:04 PM EST
You Can use Web Method and Ajax
}
samantaRank #3,157 · 454 reputationPosted Dec 23, 2014, 6:13 PM EST
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);
}