Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,791 members, 7,802,500 topics. Date: Friday, 19 April 2024 at 03:33 PM

Asp.net Mvc4 Help!! - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Asp.net Mvc4 Help!! (4506 Views)

Asp.net Mvc Deployment / My Web Development Consultancy Thread(html, CSS, Javascript, Jquery, ASP.NET) / Asp.net And Php/mysql Special Training For Programmers (2) (3) (4)

(1) (2) (Reply) (Go Down)

Asp.net Mvc4 Help!! by eugy45(m): 9:22pm On Dec 06, 2015
please i need help guys. i have an elibrary and i want each book,s decription to have their own view, but all d books description is being tied to one page. here are sme photo's:

Re: Asp.net Mvc4 Help!! by Heyzed(m): 10:04pm On Dec 07, 2015
You can create details view for the book so that by clicking the name of a particular book, it will link to detail view of that book.

You just need to reduce the information on that your list view.

If you use code first methods & you let your views generate automatically, it will have done it with the way I explain above.
Re: Asp.net Mvc4 Help!! by Raypawer(m): 12:11pm On Dec 08, 2015
you can achieve that by paginating the views display, the PagedList nuget can help you achieve that, hope you can use PagedList nuget..

nice app there
Re: Asp.net Mvc4 Help!! by eugy45(m): 1:19pm On Dec 25, 2015
Raypawer:
you can achieve that by paginating the views display, the PagedList nuget can help you achieve that, hope you can use PagedList nuget..

nice app there
Thank you i got it right now. But that pagination stuff, av dne that bt when i click on the next page it doesnt display the next content, rather shows all the same content
Re: Asp.net Mvc4 Help!! by eugy45(m): 1:23pm On Dec 25, 2015
Heyzed:
You can create details view for the book so that by clicking the name of a particular book, it will link to detail view of that book.

You just need to reduce the information on that your list view.

If you use code first methods & you let your views generate automatically, it will have done it with the way I explain above.
Thank u bro. I got that right nw, please hw do i get the quote action to capture the comment just like in nairaland. It is acttally replying the comment bt it is picking the first comment in that that post. I used firstordefault(). Bt i dnt really knw hw to query that
Re: Asp.net Mvc4 Help!! by Raypawer(m): 11:34pm On Dec 26, 2015
contact me on victorusoro@hotmail.com lets see how to figure that out

eugy45:

Thank you i got it right now. But that pagination stuff, av dne that bt when i click on the next page it doesnt display the next content, rather shows all the same content
Re: Asp.net Mvc4 Help!! by Raypawer(m): 2:29pm On Dec 28, 2015
Re: Asp.net Mvc4 Help!! by eugy45(m): 11:04pm On Dec 29, 2015
Re: Asp.net Mvc4 Help!! by eugy45(m): 6:25pm On Mar 26, 2016
Raypawer:
try this http://devproconnections.com/aspnet-mvc/aspnet-mvc-paging-done-perfectly
Sorry to disturb bro, please hw do i upload multiple images to a post..av tried alot of tins, at yet i cant achieve that. Thank u
Re: Asp.net Mvc4 Help!! by Raypawer(m): 12:19am On Mar 29, 2016
But can you Upload one?

if you can upload a single image, then add the property for the second image to the model you used to upload, but don't add the required flag and make it a nullable property..

then at the controller level, try to use some logic to check if the second image byte is empty, it should not insert as an empty byte[] to the database, as c# could be funny rather it should be left null.

eugy45:

Sorry to disturb bro, please hw do i upload multiple images to a post..av tried alot of tins, at yet i cant achieve that. Thank u
Re: Asp.net Mvc4 Help!! by eugy45(m): 12:34am On Mar 29, 2016
Raypawer:
But can you Upload one?

if you can upload a single image, then add the property for the second image to the model you used to upload, but don't add the required flag and make it a nullable property..

then at the controller level, try to use some logic to check if the second image byte is empty, it should not insert as an empty byte[] to the database, as c# could be funny rather it should be left null.

I just had to do it the long and dirty way though. I created seperate models 4 different file type. I just got soo confused looping through ienummerable of files. Thanks though!

Do u have an idea on how i can redirecttoaction using jquery.. Jus like in nairaland, so that if a user makes a comment it'll redirect him to the comment he just made. Any idea pls?
Re: Asp.net Mvc4 Help!! by Raypawer(m): 1:30am On Mar 29, 2016
each comment should have a unique id, then pass it as a parameter from the controller..

not sure if NL uses jquery

eugy45:

I just had to do it the long and dirty way though. I created seperate models 4 different file type. I just got soo confused looping through ienummerable of files. Thanks though!

Do u have an idea on how i can redirecttoaction using jquery.. Jus like in nairaland, so that if a user makes a comment it'll redirect him to the comment he just made. Any idea pls?
Re: Asp.net Mvc4 Help!! by eugy45(m): 7:15am On Mar 29, 2016
Raypawer:
each comment should have a unique id, then pass it as a parameter from the controller..

not sure if NL uses jquery

Bro av tried that.
return RedirectToAction("topics", "forum", new { id = commentId})
Its wrkin bt it only takes me to the post. Meaning that if i am in page 5 making a comment, it takes me back to page 1 after making d comment. Too bad!
Re: Asp.net Mvc4 Help!! by Raypawer(m): 7:30am On Mar 29, 2016
there is no # there that will take it to the comment bro, ok try like this and get back to me,

return Redirect(Url.Action("topics", "forum" +("#"+commentId));

without using the new keyword cos at the route table it will change it to a url parameter...

i think i found this here

eugy45:

Bro av tried that.
return RedirectToAction("topics", "forum", new { id = commentId})
Its wrkin bt it only takes me to the post. Meaning that if i am in page 5 making a comment, it takes me back to page 1 after making d comment. Too bad!
Re: Asp.net Mvc4 Help!! by eugy45(m): 8:45am On Mar 29, 2016
Raypawer:
there is no # there that will take it to the comment bro, ok try like this and get back to me,

return Redirect(Url.Action("topics", "forum" +("#"+commentId));

without using the new keyword cos at the route table it will change it to a url parameter...

i think i found this here

404 error bro
Its seeing the requested url as /forums/#commentid/topics
I dunno wat d problem is
Re: Asp.net Mvc4 Help!! by Raypawer(m): 12:33pm On Mar 30, 2016
return RedirectToAction(string.Format("topics#"+commentid), "forum"wink;

or

return Redirect(Url.Action(strint.Format("topics#"+commentId), "forum"wink;

should work..

eugy45:

404 error bro
Its seeing the requested url as /forums/#commentid/topics
I dunno wat d problem is
Re: Asp.net Mvc4 Help!! by eugy45(m): 3:16pm On Mar 30, 2016
Raypawer:
return RedirectToAction(string.Format("topics#"+commentid), "forum"wink;

or

return Redirect(Url.Action(strint.Format("topics#"+commentId), "forum"wink;

should work..

Really sorry to bother u.
The route is carrying the #commentid bt its nt taking me to the specific id rather it takes me to d postid.
I added the postid to wat u gave me:
return RedirectToAction(Url.Action(string.Format("topics"wink, new{id = postid}) + "#" + commentid)
I added d postid because in my topics action, if postid is null it throws an exception..
The whole tin gat me confused
Re: Asp.net Mvc4 Help!! by Raypawer(m): 7:44pm On Mar 30, 2016
Hope you are aware that the comment id is added to a specific position to the html, post your code at the controller level, i think i can come in from there cos you didn't mention that each post has a post id earlier..


eugy45:

Really sorry to bother u.
The route is carrying the #commentid bt its nt taking me to the specific id rather it takes me to d postid.
I added the postid to wat u gave me:
return RedirectToAction(Url.Action(string.Format("topics"wink, new{id = postid}) + "#" + commentid)
I added d postid because in my topics action, if postid is null it throws an exception..
The whole tin gat me confused
Re: Asp.net Mvc4 Help!! by eugy45(m): 10:38pm On Mar 30, 2016
Raypawer:
Hope you are aware that the comment id is added to a specific position to the html, post your code at the controller level, i think i can come in from there cos you didn't mention that each post has a post id earlier..


//Other codes are above here..........
var myquote = new ModQuote
{
UserId = WebSecurity.GetUserId(user),
PostId = model.PostId,
Comment = model.Comment,
ReplyId = model.ReplyId,
ProfileId = model.ProfileId,
By = User.Identity.Name,
File = model.File,
File1 = model.File1
};
//var last = db.MyModQuote.Where(a => a.PostId == id).AsEnumerable().LastOrDefault();
//if (last != null)
//{
// var find = db.Posts.Find(last.PostId);
//}

db.MyModQuote.Add(myquote);
db.SaveChanges();
return RedirectToAction(Url.Action(string.Format("topics"wink, new { id = id }) + "#" + myquote.ModQuoteId);
//return new RedirectResult(Url.Action("topics", "forum", new { id = id}) + "#" + myquote.ModQuoteId);
}


What am working on is a forum..something similar to nairaland, where every comment falls under a post.
Meaning that every comment has a postId
Re: Asp.net Mvc4 Help!! by eugy45(m): 2:47am On Mar 31, 2016
Raypawer:
Hope you are aware that the comment id is added to a specific position to the html, post your code at the controller level, i think i can come in from there cos you didn't mention that each post has a post id earlier..


It works now. I think it was all my fault, i 4got to add the anchor tag carryin the commentid in topics view.
But it doesnt work when d comments enter page 2. Dunno why
Re: Asp.net Mvc4 Help!! by Raypawer(m): 7:16am On Apr 01, 2016
What is the Logic you are using for Pagination? how many comments make up a page? if you are using PagedList as recommended earlier, try to append the page count to the Url..


eugy45:

It works now. I think it was all my fault, i 4got to add the anchor tag carryin the commentid in topics view.
But it doesnt work when d comments enter page 2. Dunno why
Re: Asp.net Mvc4 Help!! by eugy45(m): 9:23am On Apr 01, 2016
Raypawer:
What is the Logic you are using for Pagination? how many comments make up a page? if you are using PagedList as recommended earlier, try to append the page count to the Url..


12comments make up a page.
Am using pagination, tried tricking the page count to the url, not working
//return new RedirectResult(Url.Action("topics", "forum", new { id = id}) + "#" +
commentid, page = ...);
Cant mk reference to d current page
Re: Asp.net Mvc4 Help!! by Raypawer(m): 10:51pm On Apr 01, 2016
i have written that code before sometime last year, will check it out.. just hold on

eugy45:

12comments make up a page.
Am using pagination, tried tricking the page count to the url, not working
//return new RedirectResult(Url.Action("topics", "forum", new { id = id}) + "#" +
commentid, page = ...);
Cant mk reference to d current page
Re: Asp.net Mvc4 Help!! by eugy45(m): 7:20am On Apr 02, 2016
Raypawer:
i have written that code before sometime last year, will check it out.. just hold on

Alright Thank u
Re: Asp.net Mvc4 Help!! by Raypawer(m): 11:46pm On Apr 02, 2016
At the Controller

Add reference to PagedList and PagedList.Mvc
===========

//here i added a nullabe parameter, int? which indicates the page number, nullable because the first page will not have page count
public ActionResult Index(Guid id, int ? page)
{
//here am returning list of topics from first to 20th topic cos a page should be 20 topics
return View(topics.ToList().ToPagedList(page ?? 1, 20));
}


//same with Post actions

[HttpPost, ActionName("index"wink]
[ValidateAntiForgeryToken]
public ActionResult PostIndex(Guid id, int? page, string search)
{
var topics = TopicList();
if (!string.IsNullOrEmpty(search))
{
topics = topics.Where(x => x.SubjectS_Id == id && x.TopicName.ToLower().Trim() == search.ToLower().Trim()).ToList();
return View(topics.ToPagedList(page ?? 1, 20));
}
else
{
topics = db.Topics.Where(x => x.SubjectS_Id == id).ToList();
return View(topics.ToPagedList(page ?? 1, 20));
}
}

At the View Leve, mine was Index View

first Add reference
@using PagedList;
@using PagedList.Mvc;
@model IPagedList<MyApp.Models.Topic>

then add this where you want to have the Page Count
@Html.PagedListPager(Model, page => Url.Action("Index", "topic", new { page }),
new PagedListRenderOptions() { Display = PagedListDisplayMode.IfNeeded, DisplayItemSliceAndTotal = true })


eugy45:


Re: Asp.net Mvc4 Help!! by eugy45(m): 12:31am On Apr 05, 2016
Raypawer:
At the Controller

Add reference to PagedList and PagedList.Mvc
===========

//here i added a nullabe parameter, int? which indicates the page number, nullable because the first page will not have page count
public ActionResult Index(Guid id, int ? page)
{
//here am returning list of topics from first to 20th topic cos a page should be 20 topics
return View(topics.ToList().ToPagedList(page ?? 1, 20));
}


//same with Post actions

[HttpPost, ActionName("index"wink]
[ValidateAntiForgeryToken]
public ActionResult PostIndex(Guid id, int? page, string search)
{
var topics = TopicList();
if (!string.IsNullOrEmpty(search))
{
topics = topics.Where(x => x.SubjectS_Id == id && x.TopicName.ToLower().Trim() == search.ToLower().Trim()).ToList();
return View(topics.ToPagedList(page ?? 1, 20));
}
else
{
topics = db.Topics.Where(x => x.SubjectS_Id == id).ToList();
return View(topics.ToPagedList(page ?? 1, 20));
}
}

At the View Leve, mine was Index View

first Add reference
@using PagedList;
@using PagedList.Mvc;
@model IPagedList<MyApp.Models.Topic>

then add this where you want to have the Page Count
@Html.PagedListPager(Model, page => Url.Action("Index", "topic", new { page }),
new PagedListRenderOptions() { Display = PagedListDisplayMode.IfNeeded, DisplayItemSliceAndTotal = true })


Thanks bro. though av done that bh not working yet.
bh dont bother il still get it fixed, even if not now, someother time. thats why i love the IT world.
Planning to host the site today, paid already with smarterasp. Still trying to upload it online
Re: Asp.net Mvc4 Help!! by Raypawer(m): 8:09am On Apr 05, 2016
so are you planning to leave all the post on the same page? well, that's not the issue, just lunch it first and let it start working, you can fix it later...

eugy45:

Thanks bro. though av done that bh not working yet.
bh dont bother il still get it fixed, even if not now, someother time. thats why i love the IT world.
Planning to host the site today, paid already with smarterasp. Still trying to upload it online
Re: Asp.net Mvc4 Help!! by eugy45(m): 9:40pm On Apr 05, 2016
Raypawer:
so are you planning to leave all the post on the same page? well, that's not the issue, just lunch it first and let it start working, you can fix it later...

No i stil used pagination bt it'll stress d user a bit, after making a comment ul start lookin 4 it

Mouauconnect.com thats the site, stil under test mode, u cn tell me my flaws
Re: Asp.net Mvc4 Help!! by eugy45(m): 8:18am On Apr 08, 2016
Raypawer:
so are you planning to leave all the post on the same page? well, that's not the issue, just lunch it first and let it start working, you can fix it later...


Av got this issue now. I can create a topic from P.c and some high android phones. But when i try posting from some smart phones it gives me a null reference and i cant even trace the error cos its coming from a phone.

What could be the problem?? I have all my html helpers in order
Re: Asp.net Mvc4 Help!! by Raypawer(m): 7:20pm On Apr 14, 2016
Oh.. first time am hearing this... hav you hosted it??

what did you use to optimize you app for mobile??

and what is the error saying, where is the error pointing to?

use debugger tool so you see where your code broke down..

eugy45:


Av got this issue now. I can create a topic from P.c and some high android phones. But when i try posting from some smart phones it gives me a null reference and i cant even trace the error cos its coming from a phone.

What could be the problem?? I have all my html helpers in order
Re: Asp.net Mvc4 Help!! by eugy45(m): 10:24pm On Apr 15, 2016
Raypawer:
Oh.. first time am hearing this... hav you hosted it??

what did you use to optimize you app for mobile??

and what is the error saying, where is the error pointing to?

use debugger tool so you see where your code broke down..

Works nw.. Was 4rm my controller. Thanks
Re: Asp.net Mvc4 Help!! by Raypawer(m): 10:29am On May 24, 2016
Have u lunched the site? will like to see it,

(1) (2) (Reply)

Help On How A Make An App A Trial Version With C# / Hash Analytic Internship (A Possible Scam) / Problem With Bufferedinputstream Read Blocking Issue In Java

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 60
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.