简体   繁体   English

如何使用javascript调用ascx函数代码? DotNetNuke的

[英]How to call ascx function code behind using javascript? DotNetNuke

I have a module with code behind that submits data to a SQL table in a database. 我有一个后面带有代码的模块,该模块将数据提交到数据库中的SQL表。 I do my validation with javascript and I show a div when a button is clicked and data is valid. 我使用javascript进行验证,并且当单击按钮并且数据有效时显示div。 The problem having is when I do a postback to the server my window/browser refreshes. 问题是当我执行回发到服务器时,窗口/浏览器会刷新。 I would like to Post data to the server and show my div. 我想将数据发布到服务器并显示div。 So I think I need use ajax...problem is I am unfamilar with ajax's. 所以我认为我需要使用ajax ...问题是我不熟悉ajax。 My method that submits data to the database is in a dotnetnuke module/user control (ascx file). 我的将数据提交到数据库的方法是在dotnetnuke模块/用户控件(ascx文件)中。 Can anyone provide some direction? 谁能提供指导?

In DNN you can simply mark your ASCX file as "Supports Partial Rendering" and DNN will wrap it in an UpdatePanel, this is the easiest way to achieve the post back without the full page refreshing. 在DNN中,您可以简单地将ASCX文件标记为“支持部分渲染”,然后DNN会将其包装在UpdatePanel中,这是在不刷新整个页面的情况下实现回发的最简单方法。

You can do this by modifying you .DNN file before installation, or after installation, going to the host/extensions page, edit the module, edit the Module definition, then edit the Module control in question. 您可以通过在安装前或安装后修改.DNN文件来执行此操作,请转至主机/扩展名页面,编辑模块,编辑模块定义,然后编辑有问题的模块控件。

Edit:In the DNN file you can have 编辑:在DNN文件中,您可以拥有

<moduleControl>
<controlKey />
<controlSrc>DesktopModules/$safeprojectname$/View.ascx</controlSrc>
<supportsPartialRendering>False</supportsPartialRendering>
<controlTitle />
<controlType>View</controlType>
<iconFile />
<helpUrl />
<viewOrder>0</viewOrder>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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