简体   繁体   English

如何为Dictionary添加onclick javascript <string, string> ?

[英]how to add onclick javascript for Dictionary<string, string>?

I have a Dictionary object in my view as 我在视图中有一个Dictionary对象

<% System.Collections.Generic.Dictionary<string, string> param= new Dictionary<string, string>();; %>
<% {
    param.Add("id","AdditionalPrincipalAmount");
    param.Add("onblur", "TotalPaymentAmount()");
}  %>

does JavaScript call only work for Dictionary<string, object> or does it also work for Dictionary<string, string> ? JavaScript调用只适用于Dictionary<string, object>还是适用于Dictionary<string, string>

You're creating a dictionary here in your C# code however you don't seem to be doing anything with it. 你在C#代码中创建了一个字典,但是你似乎没有用它做任何事情。

The Dictionary itself is never present on the front end to the browser which is the main realm of Javascript. 字典本身永远不会出现在浏览器的前端,这是Javascript的主要领域。

Basically, Javascript has no knowlege of the Dictionary you create in C#. 基本上,Javascript没有您在C#中创建的Dictionary的知识。

I could be mistaken, but I don't think you can add an onclick event to a dictionary. 我可能会弄错,但我认为你不能在字典中添加onclick事件。 A dictionary is a collection, not a control. 字典是一个集合,而不是一个控件。 Not very knowledgable when it comes to MVC, but it doesn't seem logical... 谈到MVC时不是很了解,但它似乎不合逻辑......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM