+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Template with form tag - action problem

Template with form tag - action problem

7 posts, 0 answered
  1. Gaurav Mehta
    Gaurav Mehta avatar
    43 posts
    Registered:
    09 Dec 2009
    15 Dec 2010
    Link to this post
    Hi,

    We are using Sitefinity 3.6 SP1

    Recently for our site we create a new template (e.g master page).
    This page contains form tag with action and post attributes
    e.g

    action="https://www.xyz.com/login.aspx"
    method="post"

    When we tried to edit and save this template from Sitefinity admin area, instead of saving changes system will submit it to the Url given in action attribute. Same thing happens when we try to publish any page based on this template. We want to stop this behaviour.

    But at the same time when any page (using this template) on public site submit the form than it should goto Url given in action attribute.

    Please do let us know how to do this.

    Regards,
    Gaurav

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Dec 2010
    Link to this post
    Hi Gaurav,

    You can add the form from the code behind when the url does not contain cmspagemode=edit or "Sitefinity" - this means that you are in the backend so you will not generate your form or you will not set the url to it.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Gaurav Mehta
    Gaurav Mehta avatar
    43 posts
    Registered:
    09 Dec 2009
    15 Dec 2010
    Link to this post
    Hi Ivan Dimitrov,

    Thanks for your feedback.

    We actually tried to set action and method attribute from code behind of master page as per your suggestion but it did not work. :

    e.g
    protected void Page_Load(object sender, EventArgs e)
        {
           this.form1.Method = "post";
           this.form1.Action = ""https://www.xyz.com/login.aspx";
        }

    Do you have any other suggestion to fix this problem ? Please do let us know

    Regards,
    Gaurav
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Dec 2010
    Link to this post
    Hi Gaurav,

    I do not see where you check the page mode  from the query string or whether the url of the current request contains "Sitefinity" which will determine whether to set the url or event generate your form.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Gaurav Mehta
    Gaurav Mehta avatar
    43 posts
    Registered:
    09 Dec 2009
    15 Dec 2010
    Link to this post
    Hi Ivan Dimitrov,

    Can you let us know a simple code for this ? It is urgent

    Regards,
    Gaurav
  6. Gaurav Mehta
    Gaurav Mehta avatar
    43 posts
    Registered:
    09 Dec 2009
    15 Dec 2010
    Link to this post
    Hi Ivan Dimitrov,

    We just made following changes as per your suggestion and it fixes form submit problem when we save template/page from sitefinity admin area:

    protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["cmspagemode"] == null)
            {
                this.form1.Method = "Post";
                this.form1.Action = ""https://www.xyz.com/login.aspx";
            }
            

        }

    Please let us know if any additional change are required.

    Regards,
    Gaurav
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Dec 2010
    Link to this post
    Hello Gaurav,

    Here is a sample code

    var path = "Sitefinity";
    if (context.Request.RawUrl.ToLower().Contains(path) || ( HttpContext.Current.Request.QueryString[ "cmspagemode" ] == "edit" ))
    {
        //you are in page edit mode or you are browsing the backend.
    }


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
7 posts, 0 answered