|
The URL /Customers/Edit/1/ALFKI matches both the PageWithSort and PageWithId routes. As a result, the first matching route will be selected - PageWithSort - and the ALFKI string will be available as a parameter called SortColumn .
Since your action doesn't take a parameter called SortColumn , and the route doesn't contain any data for a parameter called id , the parameter will be set to null .
You can see this for yourself using the ASP.NET Routing Debugger[^] package.
You'll need to rename the parameters on your actions so that they match the parameters in the route. Since the PageWithSort route will match anything that the other two routes would, that's the one you need to match.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank you sir....have a nice day
|
|
|
|
|
HI,
suppose i am inserting new records in db and PK field may be identity type of may not. i am showing 10 records per page through skip() and take(). now how could i calculate page no where newly inserted record will appear.
give me some direction. thanks
|
|
|
|
|
It depends on many factors, such as indexing, sort order, etc.
The rest of it is clear mathematics.
|
|
|
|
|
i have seen a example of asp.net mvc routing code where two controller name has been referenced.
routes.MapRoute(
name: "test",
url: "{controller}/{action}/{page}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
defaults: new { action = "Index" }
);
just started working with asp.net mvc. so curious to know that what is the objective to mention controller or action name twice ?
in above example there is two defaults....when and why it is required.
just requesting anyone can explain the same with a nice example. thanks in advance
|
|
|
|
|
I don't know where you got that example from, but it's not valid C#. Not only are you missing a comma between the last two parameters, but you've specified the same named parameter twice.
Try to compile that code, and you'll get:
CS1740 Named argument 'defaults' cannot be specified multiple times
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
HI Sir,
please check this url asp.net mvc 4 - Using Url.RouteUrl() with Route Names in an Area - Stack Overflow[^]
in the above url you will see a example where two controller name has been mentioned.
here a small snippet.
context.MapRoute(
"UserHome",
"User/{id}",
new { action = "Index", controller = "Home", area = "User", id = 0,
httproute = true },
new { controller = @"Home", id = @"\d+" }
);
looking for your further guidance. thanks
|
|
|
|
|
That doesn't match the code in your question.
This code is calling the MapRoute(name, url, defaults, constraints)[^] overload. The second anonymous object represents the constrains on the route.
See: ASP.NET Routing: Adding Constraints to Routes[^]
It would probably be worth reading most of that article. (You can ignore the "Web Forms" section.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
sir can you give some direction that which area i need to fix in my code.
|
|
|
|
|
What code? You've shown two different code blocks, one of which won't compile. And you haven't described a problem that needs fixing with either one.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
|
thanks sir for reply.
i found the small definition and it is
Kubernetes is an open-source system for automating deployment, scaling and management of containerized applications that was originally designed by Google and donated to the Cloud Native Computing Foundation
but the image i posted it seems it is application health check apps....isn't ?
|
|
|
|
|
No,
Mou_kol wrote: Kubernetes is an open-source system for automating deployment ... If you want to know more then please go to the Kubernetes website and read the documentation.
|
|
|
|
|
Hi guys!
I am thinking of creating a payment getway like Payoneer to help my country, we are deprived of VISA cards. And the goal is to use our own currency to make local purchases.
Please help me guys.
Thank you!
|
|
|
|
|
Please do not post in multiple places: it duplicates work and that annoys people.
You already have this in QA, so leave it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
My routing code is not working.
i am showing data in tabular format with sorting and pagination. my solution is working. when i hover mouse on column then url looks like
http://localhost:55831/Customers?page=2&SortColumn=CompanyName&CurrentSort=ContactName
when i click on pagination numeric link then url looks like
http://localhost:55831/Customers?page=3&SortColumn=ContactName
i want my url should look like
1) http://localhost:55831/Customers/2/CompanyName/ContactName
2) http://localhost:55831/Customers/3/ContactName
so i add one routing code. here it is
routes.MapRoute(
name: null,
url: "Customers/{page}/{SortColumn}/{CurrentSort}",
defaults: new
{
action = "Index",
page = UrlParameter.Optional,
SortColumn = UrlParameter.Optional,
CurrentSort = UrlParameter.Optional
}
);
after adding the above routing code url looks bit weird. now url looks like
http:
http:
so when i click on above links then i am not redirecting to proper controller and action rather getting error.
so it means there is some problem in code which i added as routing in route.config.cs file.
my full routing code
routes.MapRoute(
name: null,
url: "{controller}/{action}/{page}/{SortColumn}/{CurrentSort}",
defaults: new
{
action = "Index",
page = UrlParameter.Optional,
SortColumn = UrlParameter.Optional,
CurrentSort = UrlParameter.Optional
}
);
routes.MapRoute(
name: null,
url: "{controller}/{action}/{page}/{id}",
defaults: new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional,
page = UrlParameter.Optional,
}
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
so please help me to get my desired url what i mention above. thanks
modified 2-Feb-18 5:25am.
|
|
|
|
|
Controller
public class CustomersController : Controller
{
public ActionResult Index(int page, string SortColumn, string CurrentSort)
{
return View();
}
}
route
routes.MapRoute(
name: "Customers",
url: "Customers/{page}/{SortColumn}/{CurrentSort}",
defaults: new
{
controller = "Customers",
action = "Index",
page = UrlParameter.Optional,
SortColumn = UrlParameter.Optional,
CurrentSort = UrlParameter.Optional,
}
);
razor markup
@Html.RouteLink("Click", "Customers", new { page = 1, SortColumn="CompanyName", CurrentSort="ContactName" })
@Html.RouteLink("Click", "Customers", new { page = 1, SortColumn = "CompanyName" })
|
|
|
|
|
sir please advise me how to use action link instead of routelink. i am using pagelist for pagination link...where i can not use routelink. i guess pagelist work with actionlink.
please suggest something. thanks
|
|
|
|
|
i am new to .net.please guide me. Thank You....
|
|
|
|
|
|
few questions about local db and sql express db.
1) i found many time a db with .mdf extension in app_data folder. that db is local db or sql express db?
2) is there any process which help me to determine that db type in app_data folder ?
3) what is the difference between local db and sql express db? or both is same ?
4) what is sql compact db and how it is different from local db and sql express db?
please answer point wise. thanks
|
|
|
|
|
The type of files stored in that folder depend on the application - i.e. it's up to the app developer to store whatever they want there - it may be an Access file, an SQLite file, or maybe just an XML or JSON file. You can usually tell by the file extension what sort it is.
|
|
|
|
|
i found no css section. so i place a Bootstrap related question in asp.net section.
i want to show X icon on textbox to clear textbox control's data. i tried this but not working properly.
X icon is not getting placed on textbox rather it is coming after textbox which is not right. so tell me what i am missing in code.
<div class="btn-group has-feedback has-clear">
<input id="searchinput" type="search" class="form-control" style="width:200px;">
<a
id="searchclear"
class="glyphicon glyphicon-remove-circle form-control-feedback form-control-clear"
style="pointer-events:auto; text-decoration:none; cursor:pointer;"
onclick="$(this).prev('input').val('');return false;">
</a>
</div>
jsfiddle link https://jsfiddle.net/DTcHh/42173/
|
|
|
|
|
You've linked to Bootstrap v3.0.0, which didn't include the has-feedback classes.
Update your links to v3.3.7, and your code will work.
Bootstrap 3 Template - JSFiddle[^]
FYI: for HTML and CSS issues that don't directly relate to ASP.NET, the Web Development[^] forum would be more appropriate.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|