I'm currently working on a sort of Administration method to be able to save certain text and to display this on another page.
Currently, the defaults in the "Admin" page are to be referenced from the other page. It's a simple page:
<asp:TextBox Text="Testing jQuery method" ID="TextBox" runat="server"/>
<asp:CheckBox Checked = "true" ID="CheckBox" runat="server" />
Now, the page that references these fields is actually a simple HTML file, so I'm trying to use jQuery to reference the fields. I'm trying to use a jQuery ajax call, but I can't seem to get it to work correctly.
<script type="text/javascript" src="Scripts/jquery-1.4.1.js">
var asp_checked;
var asp_text;
try {
jQuery.ajax({
url: '~/About.aspx',
success: function (response, status, xhr) {
if (status != "error") {
asp_checked = $('#CheckBox', response).text();
asp_text = $('#TextBox', response).text();
}
else { asp_text = "Error in jQuery Call"; }
},
async: false
});
document.write(asp_text);
}
catch (err) {
document.write("The jQuery is not working");
}
</script>
Things to note:
1. I don't really know much about jQuery in general.
2. I can't use cookies (I don't think). This is going onto our corporate intranet for announcements and such.
3. The jQuery code was taken from SO, but I can't recall the Question reference. When I do I will update here.
About.aspxis generating JSON.id="CheckBox"in the ASP code !=id="CheckBoxonce it makes it to HTML. (But you can play withClientIdModewithin the ASP code)