locked
InitializeCulture and the Form Collection RRS feed

  • Question

  • User-200757374 posted

    OK, I have spent way too much time on this myself, so I am hoping that someone here has an answer for me.

    I am using the InitializeCulture override and I can get it to work fine if I use a query string variable to maintain state, but I don't want to use a query string.  The MSDN documentation states that I should be able to use Request.Form to get the values of controls from my page--but I can't as their values are always null.

    I am not sure if my environment is making a difference, which is Vista Business, IIS 7, and VS2008. But it is the only environment I have!

    For example, if I say

    var x = Request.Form["CultureData"];

    x is always null. The first time in, the second time in, etc. I want "CultureData" to be a asp:HiddenField, but just to test I have also tried asp:TextBox to see if it was any different.

    Any help on this will be appreciated

    Thanks in advance,
    Jim 

    Saturday, May 1, 2010 10:02 AM

Answers

  • User-821857111 posted

    Hmmm, why wouldn't Request.Form be populated

    Don't know for sure. Are you closing the <form> too early perhaps? Are your inputs within the form tags?

    By the way, I suspect that more people are likely to disable javascript than cookies....


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 1, 2010 4:18 PM

All replies

  • User-821857111 posted

    Request.Form will only be populated if the page is posted. If it's not, you have to use a different mechanism. At the moment, you are using QueryString, which I agree is not ideal. Why not use a Cookie?


    Saturday, May 1, 2010 12:12 PM
  • User-200757374 posted

    Hi Mike and thanks for a quick reply.

    Hmmm, why wouldn't Request.Form be populated (and no, it does not appear to be) since I am using asp.net controls with post back. For example, the control I am using to switch cultures has as its hyperlink:

    javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$PageContent$lnkSwitchLanguage", "", false, "", "default.aspx?lan=es", false, true))

    Which is pretty much standard generated code <right?>.

    As far as cookies, I could, but it may not work if the client has disabled cookies--then I need a back-up plan to make it work anyway.

    Thanks again,
    Jim 

    Saturday, May 1, 2010 3:46 PM
  • User-821857111 posted

    Hmmm, why wouldn't Request.Form be populated

    Don't know for sure. Are you closing the <form> too early perhaps? Are your inputs within the form tags?

    By the way, I suspect that more people are likely to disable javascript than cookies....


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 1, 2010 4:18 PM