Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Call MVC action by Ajax, got additional HTML returned.Call MVC action by Ajax, got additional HTML returned.
Previous
 
Next
New Post
5/23/2016 8:41 PM
 

I tried to development my first MVC module in DNN8 these days.

It is a very simple demo. A button and textbox in the view. What I want is click the button to call an action in the controller and got the return string from the action, then show it in the textbox.

Here is the action code:

public ActionResult test1()
{
    return Content("Return something");
}
Here is the script:
$(document).ready(function () {
    $("#btnSub").click(function () {
        // his.action);
        $.ajax({
            type:"GET",
            contentType:"application/text",
            url: "@Url.Action("test1", "Sky")",
            data:"",
            dataType: "text",

            success: function (data) { $("#txtResult").val(data); alert("Success!") },
            error:function(){alert("Failed!")}
    });
});
});
And here is the result:
<!DOCTYPE html>
<html  lang="en-US">
<head id="Head">
<!--*********************************************-->
<!-- DNN Platform - http://www.dnnsoftware.com   -->
<!-- Copyright (c) 2002-2015, by DNN Corporation -->
<!--*********************************************-->
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><title>
	My Website > SkyMVCPage
</title><meta id="MetaKeywords" name="KEYWORDS" content=",DotNetNuke,DNN" /><meta id="MetaGenerator" name="GENERATOR" content="DotNetNuke " /><meta id="MetaRobots" name="ROBOTS" content="INDEX, FOLLOW" /><link href="/Resources/Shared/stylesheets/dnndefault/7.0.0/default.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Portals/_default/admin.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/DesktopModules/MVC/SkyDnnMvcModule/module.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Resources/Search/SearchSkinObjectPreview.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Portals/_default/Skins/Xcillion/bootstrap/css/bootstrap.min.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/admin/ControlPanel/ControlBar.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Portals/_default/Skins/_default/WebControlSkin/Default/ComboBox.DnnBlack.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Resources/Shared/components/DropDownList/dnn.DropDownList.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Resources/Shared/scripts/jquery/dnn.jScrollBar.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Resources/Shared/Components/FileUpload/dnn.FileUpload.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Portals/_default/Skins/Xcillion/css/jquery.smartmenus.bootstrap.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Portals/_default/Skins/Xcillion/Menus/MainMenu/MainMenu.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Portals/_default/Skins/Xcillion/skin.css?cdv=81" type="text/css" rel="stylesheet"/><link href="/Portals/0/portal.css?cdv=81" type="text/css" rel="stylesheet"/><script src="/Resources/libraries/jQuery/01_09_01/jquery.js?cdv=81" type="text/javascript"></script><script src="/Resources/libraries/jQuery-UI/01_11_03/jquery-ui.js?cdv=81" type="text/javascript"></script><meta name="viewport" content="width=device-width,initial-scale=1" /></head>
<body id="Body">
Lots of html information, I'm not full past it here.
I have tried lots of ways to fix it, for example, set the Ajax to return JSON, but failed
Anyone know how to fix it? 
Thanks
Sky
 
New Post
5/23/2016 11:29 PM
 

This is likely caused by DNN not having the controllers registered, so DNN responds as if it was a page requested.

 

Did you try to create this from scratch, or use my DNN Visual Studio templates?


Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
New Post
5/23/2016 11:48 PM
 

Hi Chris,

Thanks for the reply quickly.

I created it from the DNN Visual Studio templates.

Could you let me know how to register the controller?

Sorry, I have no experience in DNN MVC module development. and cannot find the tutorials or specification, so can only "try" it myself. 

Thanks.

 
New Post
5/24/2016 12:16 AM
 

Try my templates and tutorials.

http://www.christoc.com/Tutorials/DNN8-Tutorials

Here's a video for creating the module project itself.

https://www.youtube.com/watch?v=oEtGLsKGpq0


Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
New Post
5/24/2016 12:17 AM
 
Try my templates and tutorials.

http://www.christoc.com/Tutorials/DNN...

Here's a video for creating the module project itself.

https://www.youtube.com/watch?v=oEtGL...

Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
Previous
 
Next
HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Call MVC action by Ajax, got additional HTML returned.Call MVC action by Ajax, got additional HTML returned.


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out