[英]using c# in TinyMCE
I am using the tinyMCE editor. 我正在使用tinyMCE编辑器。 In the code, I have function called
getPhone()
that return string depend on the Url. 在代码中,我有一个名为
getPhone()
函数,该函数返回的字符串取决于Url。 So in the TinyMCE, I added source code like the following: <div>@(Client.Helpers.Functions.getPhone())</div>
. 因此,在TinyMCE中,我添加了如下的源代码:
<div>@(Client.Helpers.Functions.getPhone())</div>
。 I wanted that this code will show the return value from getPhone()
function. 我希望这段代码将显示
getPhone()
函数的返回值。 unfortunately, it's render it to string, and not to C# code. 不幸的是,它是将其呈现为字符串,而不是C#代码。 so in the website you can see this as a text: @(Client.Helpers.Functions.getPhone()), does anybody know why?
因此,在网站上您可以看到以下文本:@(Client.Helpers.Functions.getPhone()),有人知道为什么吗?
Do you mean by "@(...)" as C# standard inline code (ie <%= %>)? 您是用“ @(...)”表示C#标准内联代码(即<%=%>)吗? If so, remember that when ASP.Net is rendering your page it puts different content at appropriate positions in the page from source data.
如果是这样,请记住,当ASP.Net呈现页面时,会将不同的内容放在源数据中页面的适当位置。 This implies that your C# related codes that are presented in the Tiny Editor will NOT be recognized for rendering to Html at render time.
这意味着在Tiny Editor中呈现的与C#相关的代码在渲染时将无法识别为渲染为HTML。
To solve the problem, you would have 2 options: 要解决该问题,您将有2个选择:
1) Assume a custom phrase for phone like "[PHONE]" and find for that phrase in any text that is pulled out from DB and replace with the appropriate phone number based on your logic 1)假设一个电话的自定义短语,例如“ [PHONE]”,然后在从数据库中提取的任何文本中找到该短语,并根据您的逻辑替换为适当的电话号码
or 要么
2) Extend the TinyMCE javascript lib and add a custom button that inserts a script block and a tag in the caret position in the editor. 2)扩展TinyMCE javascript库,并添加一个自定义按钮,该按钮在编辑器的插入符号位置插入脚本块和标签。 The script makes a callback to server and calls the getPhone() method and puts the result in the mentioned , with considering unique id for the whole process!
该脚本对服务器进行回调并调用getPhone()方法,并将结果放入提到的过程中,并考虑整个过程的唯一ID!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.