【发布时间】:2020-06-23 02:41:04
【问题描述】:
string empCode = ds.Tables[0].Rows[i]["EMP_CODE"].ToString();
string empName = ds.Tables[0].Rows[i]["EMP_NAME"].ToString();
string gradeCode = ds.Tables[0].Rows[i]["GRADE_CODE"].ToString();
tr = new TableRow();
td = new TableCell();
td.Attributes.Add("onClick", "javascript: " +
"if(confirm(empName)==true){self.close();}" + //this Line
"else{return;}");
我想在注释部分重复使用 empName。 有没有办法重复使用它?
【问题讨论】:
-
您可以像这样将值内联到生成的javascript中
$"if(confirm('{empName}')==true){self.close();}" -
如果这样做,就不能使用变量。
-
你到底想做什么?把变量值放在那里还是用它作为那个代码字符串中的变量?
-
我想在javascript中使用c#中声明的变量。
标签: javascript c# html asp.net