[英]DNN Form not processing correctly with ASP.NET c#
I've encountered a problem with a Dot Net Nuke customized form. 我遇到了Dot Net Nuke自定义表单的问题。 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.
我在c#后面有提交按钮代码,可以在触发时重定向到另一页,并在函数末尾使用代码“ response.redirect()”。 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. 如果站点不崩溃,我将无法更改或删除dnn代码。 It seems like the dnn code will override my c# response.redirect code.
似乎dnn代码将覆盖我的C#response.redirect代码。
You can't have a form inside DNN because the DNN page is a form itself. 您无法在DNN中拥有表单,因为DNN页面本身就是表单。 Check out the editUrl() functions to change where the page posts to.
检出editUrl()函数以更改页面发布到的位置。 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. 要进一步扩展:cmdblah.Click事件显然与页面上的按钮控件绑定在一起。
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. 在我的情况下,重定向在DNN上执行了另一个页面却不发送任何内容,但是,我可以看到通过添加的url中的参数或其他方式发送信息。...如果遇到这种情况,请找我。 :-) 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. 过去,我对此的解决方案是调用一个javascript,以在单击按钮/链接时更改表单动作。
The issue with this is it send the view state and all the dnn specific suff as well as the fields intended. 这样做的问题是它发送视图状态和所有dnn特定的后缀以及所需的字段。
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"; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.