Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kishore 19 posts 40 karma points
    Dec 13, 2011 @ 12:54
    Kishore
    0

    Form submit not working when using with altTemplate

    Hi,

     

    I've created the contact us form for the desktop version and it is working fine.

    Later I've added mobile template for the contact us page and I'm using altTemplate in order to use the mobile template.

    After filling the form and hit submit it reloads the page in the desktop version template and form values does not submitted to the server.

    I'm not sure what I'm missing here.

    Much appreciated your help ASAP as we need to go live at the earliest.

    Thanks,

    Kishore

  • Comment author was deleted

    Dec 13, 2011 @ 12:57

    And does it submit if you try the mobile template on your desktop machine?

  • Kishore 19 posts 40 karma points
    Dec 13, 2011 @ 13:10
    Kishore
    0

    Hi Tim,

    No it does not submit. It just reloads the page in desktop template.

     

    Thanks

    Kishore

  • Kishore 19 posts 40 karma points
    Dec 14, 2011 @ 10:22
    Kishore
    0

    Hi,

    I've managed to find out the cause of the issue. Some how the altTemplate parameter is coming as empty string on postback.

    After adding the altTemplate on postback resolved the issue.

    Thanks Tim for your input.

    Regards

    Kishore

  • bob baty-barr 1180 posts 1294 karma points MVP
    Dec 14, 2011 @ 16:11
    bob baty-barr
    0

    @Kishore

    also to note, if you are using jquery mobile -- you need to disable ajax for the form -- just ran into that the other day.

    i have been using 51Degrees mobi and a very simple script running in app_code to switch the template before the page is served -- negating the need for altTemplate.

    Let me know if this is of interest to you -- i could post some more details.

  • Kishore 19 posts 40 karma points
    Dec 15, 2011 @ 12:44
    Kishore
    0

    Hi Bob,

    Please post some more details which will be handy in my case.

    Thanks

    Kishore

  • bob baty-barr 1180 posts 1294 karma points MVP
    Dec 15, 2011 @ 16:24
    bob baty-barr
    0

    first be sure to have a mobile domain pointed at your site -- i use m.[mysite].com

    then download the 51DegreesMobi package here... http://our.umbraco.org/projects/website-utilities/51degreesmobi-foundation

    next, you need to edit the 51Degrees.mobi.config which is found in app_data folder

    this edit will set the redirect for mobile devices... mine looks like this...

     

    <redirect 
    firstRequestOnly="true"
    mobileHomePageUrl="http://m.northernrehabpt.com/"
    timeout="1"
    devicesFile="~/App_Data/Devices.dat" ></redirect>

    next, you have to add this code to file in your app_code folder -- i call it switchMobile.cs -- you can call it whatever you want.

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using umbraco.BusinessLogic;
    using umbraco;
     
    namespace Level2.Events
    {   
    public class TEMP_changeTemplateToMobile : ApplicationBase
        {
           public TEMP_changeTemplateToMobile()
            {
                UmbracoDefault.BeforeRequestInit += new UmbracoDefault.RequestInitEventHandler(UmbracoDefault_BeforeRequestInit);
            }
            void UmbracoDefault_BeforeRequestInit(object sender, RequestInitEventArgs e)
            {
    HttpContext.Current.Trace.Warn("mttDebug", HttpContext.Current.Request.UserAgent.ToString());
                var page = (UmbracoDefault)sender; 
    if (HttpContext.Current.Request.Url.Authority.StartsWith("m."))
                {
                    page.MasterPageFile = page.MasterPageFile.Insert(page.MasterPageFile.LastIndexOf("/") + 1, "Mobile");
                }
            }
        }
    }

    Lastly... the way this is set up... it intercepts the page request and sets the template to be Mobile[originalTemplateName] -- so, you need to create a set of templates for your mobile site that match those template names... hope that makes sense.

     

     

  • Kishore 19 posts 40 karma points
    Dec 16, 2011 @ 13:44
    Kishore
    1

    Great stuff bob!

    Thanks

    Kishore

Please Sign in or register to post replies

Write your reply to:

Draft