I’m using FileTree JQuery component to pass a directory selection to the page. I’m using HTTPGet to pass the selected file and catch it on Page_Load (so far, so good!).
After this, i want to make some changes on page and “refresh” controls.
What is the best approach to do this?
Thx!
JQuery Function:
function LoadImages(file) {
var param = {
"Action": "LoadImages",
"file": escape(file)
};
$.getJSON("SomePage.aspx", param);
}
Code-Behind (aspx.cs)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (QueryString.Current.Get(Constants.HTTPGet.Action) == Constants.HTTPGet.LoadImages)
{
DoSomethingWithFile(Request["file"]);
divAnything.Visible= true;
}
}
}
Your code is running when the page is not a post back.
Try taking the code segment outside the check, and see if that was the issue for you.
(ideally, you can check using breakpoints, if your code is being accessed).
i.e.
Always remember that if you have an action in your page, and you need the ASP.NET engine to process it, you’ll need to send the page back.
In javascript, you can force a postback caling the form’s submit method, or with a control that has a postback event to it.
i.e in JavaScript.
i.e in jQuery.