简体   繁体   中英

JQuery Function Asp.net pass by reference

So I am trying to call a function from Code Behind. The Jquery function I am trying to call is the JSON editor jQuery plugin as seen here: http://www.daviddurman.com/jquery-json-editor-plugin.html and the source can be found here: https://github.com/DavidDurman/FlexiJsonEditor

In my aspx file I have something like ..

<div id="editor" class="json-editor"></div> 
<pre id="json"></pre>
<script src="Scripts/json/jquery.min.js"></script>
<script src="Scripts/json/jquery.jsoneditor.js"></script>
<asp:Label runat="server" ID="jsonlabel" Width="400"></asp:Label>

In my codebehind I set "result" and I call this

string jquerystring = "var json = "+result+";" + "$('#editor').jsonEditor(json, change: function() { $('#jsonlabel').text(JSON.stringify(json));} });";
ClientScript.RegisterStartupScript(GetType(), "json", "<script type=\"text/javascript\">"+ jquerystring +"</script>");

So basically I am trying to update the 'jsonlabel' text when 'json' changes. The thing is the 'json' object always remains the same.. I know that the change function() is being called whenever I make edits (I tried using a messagebox to prove this) but for some reason the 'json' object always stays the same.. and hence, my 'jsonlabel' always has the value of the original 'resulstring'

Nevermind I fixed it. I misread the documentation -> http://forums.asp.net/post/5456160.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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