Click here to Skip to main content
15,891,733 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Authentication/Authorisation Pin
Richard Deeming17-May-19 1:03
mveRichard Deeming17-May-19 1:03 
GeneralRe: Authentication/Authorisation Pin
Mycroft Holmes17-May-19 12:44
professionalMycroft Holmes17-May-19 12:44 
QuestionQuestion about empty button top positioning. Pin
neodeaths11-May-19 12:39
neodeaths11-May-19 12:39 
AnswerRe: Question about empty button top positioning. Pin
Richard Deeming13-May-19 8:09
mveRichard Deeming13-May-19 8:09 
QuestionWeb API Not Working Pin
Kevin Marois10-May-19 10:57
professionalKevin Marois10-May-19 10:57 
AnswerRe: Web API Not Working Pin
Richard Deeming10-May-19 11:12
mveRichard Deeming10-May-19 11:12 
QuestionNeed Some Of Your Help Pin
Member 143595087-May-19 21:12
Member 143595087-May-19 21:12 
QuestionMVC5 Load partial view on link click Pin
#realJSOP4-May-19 6:52
mve#realJSOP4-May-19 6:52 
I'm trying to render JUST a partial view (without re-rendering the entire page) in the existing page when I click a link.

I have the following in my home controller:
C#
// both of the specified partial views do in fact exist in the Views/Shared folder
public ActionResult AppInfo()
{
	return View();
}

public ActionResult AppInfoAbout()
{
    return PartialView("_About");
}
public ActionResult AppInfoContact()
{
    return PartialView("_Contact");
}
I have the following in my AppInfo.cshtml
HTML
<!-- the razor vars you see in this sniuppet all contain the appropriate values -->
 <div style="display:flex;flex-direction:row;">
    <div style="width:150px;">
        <a href="@btnLinkAbout"   class="btn btn-primary aef-app-info about-btn">@aboutBtnText</a>
        <br/>
        <a href="@btnLinkContact" class="btn btn-primary aef-app-info contact-btn">Contact Us</a>
    </div>
    <div style="width:850px;">
        <div id="siteInfoContent" >
            <span>Click one of the buttons at the left of this box to view the associated content.</span>
        </div>
    </div>
</div>
This is the jquery I'm using:
JavaScript
<script>
$('.aef-app-info').on('click', function(evt) {
    evt.preventDefault();
    evt.stopPropagation();

    var $contentDiv = $('#siteInfoContent'),
        url = $(this).data('url');

    $.get(url, function(data) { $contentDiv.html(data); });
});
</script>
If I run it with the javascript as presented, it renders the entire AppInfo view (without the selected partial view) in the siteInfoContent div. If I comment out evt.preventDefault();, it renders just the desired content as if it were a whole new page.

What am I doing wrong?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

AnswerRe: MVC5 Load partial view on link click Pin
jkirkerx5-May-19 13:53
professionaljkirkerx5-May-19 13:53 
GeneralRe: MVC5 Load partial view on link click Pin
#realJSOP6-May-19 1:38
mve#realJSOP6-May-19 1:38 
AnswerRe: MVC5 Load partial view on link click Pin
Richard Deeming8-May-19 1:31
mveRichard Deeming8-May-19 1:31 
Questiononline distance learning management system Pin
Sibanda Benon30-Apr-19 20:42
Sibanda Benon30-Apr-19 20:42 
AnswerRe: online distance learning management system Pin
Kevin Marois2-May-19 10:12
professionalKevin Marois2-May-19 10:12 
QuestionHow To Run Website Without Web Hosting Pin
Kamakoti Satish Kumar23-Apr-19 1:13
Kamakoti Satish Kumar23-Apr-19 1:13 
AnswerRe: How To Run Website Without Web Hosting Pin
#realJSOP23-Apr-19 5:28
mve#realJSOP23-Apr-19 5:28 
AnswerRe: How To Run Website Without Web Hosting Pin
Nathan Minier23-Apr-19 18:53
professionalNathan Minier23-Apr-19 18:53 
AnswerRe: How To Run Website Without Web Hosting Pin
Rajesh Murthy S15-May-19 19:48
Rajesh Murthy S15-May-19 19:48 
QuestionFlask/React/Mongo - Clues, hints, tips or gotchas Pin
Nagy Vilmos16-Apr-19 22:43
professionalNagy Vilmos16-Apr-19 22:43 
QuestionRazor Pages and Layout.cshtml Pin
Mycroft Holmes16-Apr-19 22:23
professionalMycroft Holmes16-Apr-19 22:23 
AnswerRe: Razor Pages and Layout.cshtml Pin
Maciej Los16-Apr-19 23:17
mveMaciej Los16-Apr-19 23:17 
GeneralRe: Razor Pages and Layout.cshtml Pin
Mycroft Holmes19-Apr-19 15:35
professionalMycroft Holmes19-Apr-19 15:35 
AnswerRe: Razor Pages and Layout.cshtml Pin
#realJSOP22-Apr-19 2:50
mve#realJSOP22-Apr-19 2:50 
GeneralRe: Razor Pages and Layout.cshtml Pin
Member 143592847-May-19 16:45
Member 143592847-May-19 16:45 
QuestionFatal error: Uncaught Error: Call to a member function prepare() Pin
Member 1426306215-Apr-19 20:49
Member 1426306215-Apr-19 20:49 
AnswerRe: Fatal error: Uncaught Error: Call to a member function prepare() Pin
Richard MacCutchan15-Apr-19 21:25
mveRichard MacCutchan15-Apr-19 21:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.