Session variables to protect from FileUploads Browse?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
7/12/2007 7:51:49 AM
Gravatar
Total Posts 112

Session variables to protect from FileUploads Browse?

Hi All,

Perhaps I am using the wrong approach on a Module I am working on; so I would appreciate some guidance!

The user selects a GridView item then FileUploads an image. The GridView selection saves which GridView item in a variable then the FileUpload Browse refreshes the page and my variable becomes null. I've tried to use Session["VariableName"] to retain the variable around the FileUpload Browse but have not been able to figure out how to use Session Variables without errors.

So following in my current direction I'd like to know how to use Session Variables in a mojoPortal Module... But wiser minds than mine might suggest a different direction for me to take and I would be happy to hear that also!

Metta,
Dale E. Moore

7/12/2007 3:26:54 PM
Gravatar
Total Posts 112

Re: Session variables to protect from FileUploads Browse?

Hi All,

One thing I've tried is this:

System.Web.HttpContext.Current.Session["ServiceOrderID"] = 0;

And I get the following error messages...

  1. Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)
  2. Invalid token '=' in class, struct, or interface member declaration

Any suggestions you have are very much appreciated,
Dale E. Moore

7/13/2007 7:54:36 AM
Gravatar
Total Posts 18439

Re: Session variables to protect from FileUploads Browse?

Hi Dale,

Session variables are a developer convenience but don't scale very well. I never use them unless its absolutely necessary which is hardly ever.

I'm not sure I understand what problem you are having.

"FileUpload Browse refreshes the page and my variable becomes null."

Browsing for a local file does not refresh the page. Are you talking about the user then clicks the upload button and posts back the page? Then perhaps after postback you are redirecting the page. You should surely still have your variable during postback. Why not just put the variable in the query string. After succesfull upload if you still need to have the current item selected you could response.Redirect("yourpage.aspx?yourvariableid=" + yourvariable);

Then read it from the query string to do the selection.

A similar problem and solution can be found in Admin/PageTree.aspx, where moving the page up or down the tree is a postback but I keep the page selected using a query string param and response.redirect.

Hope it helps,

Joe

7/13/2007 1:12:32 PM
Gravatar
Total Posts 112

Re: Session variables to protect from FileUploads Browse?

Dear Joe,

Your feedback continues to be VERY VALUABLE to me! I appreciate you pointing out where my questions have been vague or difficult to understand; this leads me to learn how to speak better about the issues I encounter. In spite of my not explaining well the issues I encounter, you provide useful insights that lead me to workable solutions!

I have implemented some

WebUtils.SetupRedirect(this, SiteRoot + "/tech.aspx?SOID=" + ServiceOrderID + "&IID=" + ImageID);

and

private void LoadSettings()
{
ServiceOrderID = WebUtils.ParseInt32FromQueryString("SOID", -1).ToString();
ImageID = WebUtils.ParseInt32FromQueryString("IID", -1).ToString();
}

following your Admin/PageTree.aspx example and it's working fine now!

Thanks for taking the time!
Dale E. Moore

You must sign in to post in the forums. This thread is closed to new posts.