asp.net-mvc


overload ActionResult


this is my action "Index"
when i first go to page i dont have the "pageParent"
so i dont get the page.
just if i enter to it like this "http://localhost:50918/Page?pageParent=1" it's enter.
how to make "http://localhost:50918/Page" to work?
public ActionResult Index(int pageParent)
{
var id = pageParent;
var pages = (from p in db.pages
where p.pageParent == id
select p);
PageParentModel model = new PageParentModel();
model.page = pages;
model.pageParent = id;
return View(model);
}
Modify your Action like this
public ActionResult Index(int? pageParent) {
// this way your pageParent parameter is marked to be nullable
// dont forget to check for the null value in code
}
You can set a default value for use too in the case that the parameter isn't supplied in the querystring - e.g.:
public ActionResult Index([DefaultValue(1)] int pageParent) {
}

Related Links

Call a Web API from MVC controller (cookie authentication)
asp.net MVC 5 - split registration over several pages. How can I still use [Required] annotations?
External component has thrown an exception after framework upgrade on server
Asp.net www redirect to non www
Bootstrap Glyphicon Popover
how to return to filled out form from other view in mvc
Edit page with a foreign key constraint fails in Asp.net MVC
MVC pass int from view to controller with a button click
PCL Attribute not seen in MVC ModelMetaDataProvider
How to a publish visual studio solution with two dependencies projects to azure?
EF Core + MVC 6 + .NET Core RC2 - EF not returning results
Can we display linq result in view without using model
EF - work with universal entity in library project, when not specified database entities
asp.net core not detecting classlibrary Model on View during runtime
Using Ajax.BeginForm helper in MVC 5 for uploading picture issue [duplicate]
Decorating class with Authorize assumes Office 365 login, instead of offering choice

Categories

HOME
mocking
printing
dicom
orbeon
direction
react-navigation
apacheds
word-vba
xamarin.forms-listview
intel-xdk
box
jasypt
webdriver-io
telerik
predictionio
regression
eps
tcplistener
editor
condor
jquery-selectors
helpers
javers
silk-performer
game-maker-language
realm-java
code-analysis
spark-graphx
ibm-datapower
azure-ad-graph-api
zos
eonasdan-datetimepicker
smallbasic
dsl
jtable
fat-free-framework
shinydashboard
codeceptjs
gcp
photo-gallery
machine-language
inria-spoon
gradient-descent
extraction
uistoryboardsegue
rft
freerdp
httpexception
oracle-aq
clientscript
jasmine2.0
database-cleaner
hipi
zbar
gpt
graph-traversal
swift-package-manager
geneticsharp
plotrix
ipopt
git-config
jsbin
statistics-bootstrap
ocsp
codeigniter-upload
4d
securesocial
okuma
id3
js-of-ocaml
screen-capture
rdotnet
treegrid
crowdflower
setattribute
servlet-listeners
ratingbar
grunt-contrib-copy
hebrew
libtorrent-rasterbar
llblgenpro
emitmapper
semantic-markup
visual-assist
java-ee-5
lungojs
intel-8080
consistent-hashing
stumbleupon
nntp
paredit
nscollectionviewitem
rails-3.1
noaa
automapping
excel-web-query
coords

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App