I need to do something that can only be processed on server side and not by just using javascript on the html page. I'm already using this process for my other aspx pages. However, this time I need to make this work on an html page.
The workaround that I have done so far is to have an iframe somewhere in my html page that points to an aspx page. I do the process on its code behind and save what I need on a hidden field in the iframe. I can now get that value from the iframe and use it on my html page.
It works but I'm thinking that there might be a simpler approach in doing this without having to create a new aspx page just for processing. Is there another way to accomplish this?
UPDATE: To be specific, I need to get the location(country) of the user on page load in order to change the css accordingly. I know there are a lot of sites that I can connect to on my page to do this but I don't know which one is secured. Also, we already have our own method to this for our aspx pages so I want to use that instead. Hope this update helps.
Here is how I would do what I think you are explaining. Your question was not very clear.
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
$.ajax({
type: "POST",
url: "PageName.aspx/MethodName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do something interesting here.
}
});
HTML
<html>
<head>
<title>Calling a page method with jQuery</title>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="Default.js"></script>
</head>
<body>
<div id="Result">Click here for the time.</div>
</body>
</html>
JS
$(document).ready(function() {
// Add the page method call as an onclick handler for the div.
$("#Result").click(function() {
$.ajax({
type: "POST",
url: "Default.aspx/GetDate",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Replace the div's content with the page method's return.
$("#Result").text(msg.d);
}
});
});
});
But again I really have no idea what you are trying to do. You were really vague.