Cross Page Postback and passing info from source to destination page
I have a FileUpload
control in the Source page. On 开发者_如何学Gothe Upload button handler, I read the file into memory (after doing some validations) and since it's always going to be a TXT file, I create a string that I need to pass to the Destination page.
I thought of using Cross Page postback and set the PostBackUrl
property of the upload button. But it appears that the breakpoint in the Upload button handler is never hit. It directly goes to the Page_Load
in the Destination page.
If I can't use Cross Page postback and don't want to use Session or the database, how do I pass this string from Source page to the Destination page?
Anyone?
You can use HTTPContext object to do this. Just add your values to context like this
Context.Items["Myvariable"] = "myValue";
See The HttpContext Items Collection
I ended up using Session
精彩评论