简体   繁体   中英

DNN Form not processing correctly with ASP.NET c#

I've encountered a problem with a Dot Net Nuke customized form. The form has some strange behavior. Well I believe the skin itself in the code is strange. I have the submit button code behind c# to redirect to another page upon firing, using the code "response.redirect()" towards the end of the function. However, it redirects back to itself without any action specified in the page. I realized that when I view the source code, it automatically gives an action to return to itself.

The code in the skin itself follows:

<dnn:Form id="Form" runat="server" ENCTYPE="multipart/form-data" >

The button code:

<asp:button id="btnClear2" cssclass="dnnSecondaryAction " runat="server" resourcekey="Submit"
  onclick="btnSubmit_Click" />

The form after being processed displays in the browser as:

<form name="Form" method="post" action="/onlineorderform.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="Form" enctype="multipart/form-data">

I'm not able to change or remove the dnn code without having the site to crash. It seems like the dnn code will override my c# response.redirect code.

You can't have a form inside DNN because the DNN page is a form itself. Check out the editUrl() functions to change where the page posts to. I'm currently trying to get around the problem myself.

To further expand: cmdblah.Click event obviously tied into a button control on the page.

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        cmdblah.Click += cmdblah_Click;

}

        private void cmdblah_Click(object sender, EventArgs e)
    {
        string Testing = EditUrl("AddNewClient");
        Response.Redirect(Testing);

        //throw new NotImplementedException();

    }

In my case that redirects do another page on DNN without sending anything, however, I could see sending information through parameters in the url that you add, or some other way.... which if you run across, get back at me. :-) I just haven't gotten that far yet. I'd imagine it would be sending the post data to the new page anyway.

Hope that helps.

As the whole page in the site is a form you can not create forms within the page.

My solution to this in the past is has been to call a javascript to change the form action on click of the button/link.

The issue with this is it send the view state and all the dnn specific suff as well as the fields intended.

On my latest project I used a selector class on the form fields to be sent and query to serialise and post the data. worked well in the end.

EDIT:

below is some code that will allow you to serialise part of your form and send it

        $.get('processor URL' , 
        $('.ClassAddedToFieldsYouWantToSend').serialize(), 
        function(data) { alert("do something with the response"; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM