开发者

Dynamic controls in updatepanel not posting in Opera Mobile

I have a page to which I am adding a dynamic UpdatePanel with more dynamic controls in it's ContentTemplateContainer. ViewState is disabled on the ContentTemplateContainer because the entire state can be recreated on postbacks from a single ID in a HiddenField like so:

        if (request.HttpMethod == "POST")
        {
            string ctrlName = request.Params.Get("__EVENTTARGET");
            int yearID = int.Parse(request.Form["hfPrevYear"]);
            if (!string.IsNullOrEmpty(ctrlName) && ctrlName == "btnYearUp")
            {
                yearID = getNextDataYear(di.getTestData(), yearID);
            }
            else if (!string.IsNullOrEmpty(ctrlName) && ctrlName == "btnYearDown")
            {
                yearID = getPrevDataYear(di.getTestData(), yearID);
            }
        }

The problem is that Opera Mobile is not posting the hidden field, causing my page to throw an exception when it tries to parse that value. It only posts controls outside the update panel like the hidden fields that ASP.NET adds for viewstate and event target. When I was stepping through the postback code in Dragonfly, I notice that the documen开发者_JS百科t.forms[0].elements[] collection doesn't include my controls, which is what the updatepanel code loops through to build the post request.

Other browsers post the field just fine, including Opera Mini and Desktop Opera.

Any idea what's going on here?

Thanks for the help, --Nick


Since you haven't posted an example, I can only give you some general tips. My best guess is that the core version of Opera mobile may have a bug that's already fixed in Opera desktop/Mini.

Make sure your markup inside the form is correct - if tags are in the wrong order somewhere, for example something like

<p><b></p></b>

it can confuse the parser, and an example of such confusion might be that a form is closed too early and controls end up "outside" it. The validator.w3.org service can help you find such problems.

Also, check that tags that need closing do have a closing tag, for the same reason.

How are the elements added to the form - are they in the markup from the beginning, or added with JavaScript? If the latter, try adding them to the form itself explicitly (document.forms[x].appendChild().. rather than appending them to an element you think is inside the form).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜