Web Forms :: Generating URL From Route?
Mar 20, 2011My app in not MVC style, its WebForms style
View 3 RepliesMy app in not MVC style, its WebForms style
View 3 RepliesI tried to mix asp.net 4 webfrom and ASp.Net MVC 3. I add required lines in webconfig, but I've issues implementing route in global.asax
Currently I use several routes for webfroms. routs template are like below
routes.MapPageRoute("Node", _
"article/sport/{nID}/", _
"~/article/articleview.aspx")
I encounter error, when I add below lines to global.asax
routes.MapRoute( _
"Defaultss", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
)
I want to know how could I mix ASp.Net MVC routes with webforms routes.
when i run the app i got this error
A route named 'Admin_default' is already in the route collection. Route names must be unique.
Parameter name: name
this is my AdminAreaRegistration
[Code]....
I have a url that I want to map routing to:
[URL]
where tabvalue is one of: "personal", "professional", "values" or nothing.
I want to map it to a route like:
Member/Edit/{tab}
But my problem is - I don't know how to specify such constraints. I'm trying this regex:
^[personal|professional|values]{0,1}$
but it only works when I use url
[URL]
[URL]
and doesn't work for
[URL]
how to specify the correct constraint?
P.S. I'm not using MVC, just asp.net WebForms
Was looking at asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL.
My custom route handler is basically a wild-card handler. It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible? Or do I essentially need to code the mappings that used to exist in my global.asax into my custom route handler?
I have a product-page and a department-page. Both departments and products are picked from a database by their id (productid and deptid).
When I try to route like this, it seems that only the first rule is applied, Why? How can I solve this?
In global.asax:
[Code]....
With the above settings I can reach
http://mysite.com/myproduct.aspx but not
http://mysite.com/mydepartment.aspx.
If I switch so that the DeptList rule comes first "mydepartment.aspx" works but not "myproduct.aspx"....
I know that this issue has been raised on so many occasion and I am stuck with two options, one being to create a thumbnail folder whenever a picture is uploaded to the server, here I am using a folder with so many subfolder, upon saving on the server folder, I pass in the subfolder name and the file name, to retrieve the image i need the two parameters but also the resize sizes and as such this measure is almost abosulte.
the other way is to resize on the fly when the user is requesting the picture, this is where I have been stuck on and need some guidance. and here is the code
[Code]....
I am building an application in Asp.Net 4.0 (Web Forms). I have used the feature of Routing introduced in this version of Asp.Net (4.0).
I have a few routes declared in my global.asax file. My problem is as long as the number of parameters (placeholders) declared in the route are different the right route is selected. But the moment the number of parameters (placeholders) declared in the route are same there is a clash and the Routing engine selects the wrong route. The only way I found was to use a Constant with one of the clashing routes to distinguish between the two. But I am sure there is a way out of it; I also tried using Regular Expression but still it selects the wrong route.
[Code]....
The last two routes have the same number of parameters so I tried to separate the second last route by adding a regular expression, but in vain.
I have an application that I am trying to add url routing to. Part of my application though, looks at the requested page, and looks for a folder that the file requested is in, and applies different rules depending on the folder. For example, the two files
~/Folder1/page.aspx
and
~/Folder2/page.aspx
would have some different rules applied to them because they are in different folders.What I need to do, is get the actual file information from a request when that request comes from a routed url. I do not need the entire file path, just the relative path. Essentially, I am looking to retrieve the value of the third argument in the MapPageRoute method, e.g.
routes.MapPageRoute(
"RouteName",
"RouteURL",
"~/Folder/Default.aspx"
[Code]....
works okey in aspx codebehind. However, how can I get the same parameter value from an ascx file codebehind.
I have a web application which will write a set of values returned from
View 4 RepliesI want to add multiple DropDownLists to my ASP.NET page with C# when another dropdownlist changes.It works with one DropDownList but my problem is that I want to create new ones in a for-loop.
This is what I have now:
[Code]....
I would like to use something like this (I understand that this is wrong but hopefully you get the point):
[Code]....
Looking at the asp.net v4 URL Routing it's easy to see how to access routing data from basically anywhere in the app.
Via: Page.RouteData.Values["blah"]
Unfortuantely the Route data always is blank by the time i hit the page on my v 3.5 implementation of routing. I was wondering if there was any way to either pass the route values to the final page so i can use them there - i really don't want additional logic in my handler file and i have loads of Routes and don't want many RouteHandlers.
If I have the following routes:
RouteTable.Routes.MapPageRoute("route1", "products/{cat1}/{cat2}.aspx", "categories.aspx");
RouteTable.Routes.MapPageRoute("route2", "products/{cat1}.aspx", "categories.aspx");
And am at this url:
products/door/steel.aspx
I would like to use Response.RedirectToRoute to redirect to "products/tools.aspx".
Response.RedirectToRoute(new { cat1 = "tools" }); redirects to "products/tools/steel.aspx"
Response.RedirectToRoute(new { cat1 = "tools", cat2 = "" }); redirects to "products/tools.aspx?cat2=steel"
Response.RedirectToRoute("route2", new { cat1 = "tools" }); redirects to "products/tools.aspx?cat2=steel"
Basically it seems the existing route values are being used in the redirect instead of what I specify. This behaviour can make sense, since it makes it easy to redirect to a url with only one route value different. But why when I specify it to be empty or specify what route to use does it add the existing value as a querystring argument, and is there a way around this?
I've a WebForm with a HTML table and I need to add hyperlinks in a column. The amount of hyperlinks depend on the rows in a table.Can someone tell me how can I do that?
View 2 RepliesI have a simple function that is supposed to create a string of year values(separated by a comma) from a form that contains checkboxes for a set of years.
[Code]....
The problem is, it is doubling data somehow. For example, if I check the checkboxes for 2008, 2009, 2010, it will return :
,2010,2010,2009,2010,2009,2008
But I can't figure out why it is doing this...is there something I am doing wrong?
I have an existing app that has a java based search utility - this search utility has a FILTERing mechanism. You can click a button to POSTBACK to the server and there, a new window is generated displaying "blah dee da".
So, click a button to filter the utility, click a button to postback and voila, you get your popup aspx.
Unfortunately, the old aspx loses STATE when on the round trip and refreshes itself too - i lose my filter.
How do I go about NOT losing my STATE ?
I understand that specifying the following in the FORM tag on the old ASPX: target="_blank"
takes the focus away from the old aspx and so, the STATE is not lost. However, when the popup generates, a brand new aspx is created along with the asps pop-up. So, I end up with 3 aspx forms!
In my site I have no App_Code folder, no Bin folder, no codebehind files, and no web.config. I need to make a form that exports an Excel spreadhseet filled with database results. Anything I do has to run out of the inline script runat="server" block at the top of the page.
View 2 RepliesI have a toolbar on my chart:
[Code]....
For the SaveImage, I want to be able to set my image name with its own name.
the name can be found using:
string fileName = Request.PhysicalApplicationPath + @"graphs"+User.Identity.Name+graphID+".jpg";
Right now, when I click save, it always show chart.png
And also, I want to download the chart as jpg.
I am using URL Routing to route user to his profile page, which is a child page. Now the problem is that all the images, javascripts references are distorted when i user the url to reach that page whether logged in or not logged in (both the cases). But after reaching this page when i login from this page thru my modal popup login control, all the references seem to work fine. It is to be noted that i am still in that same page which i reached after url routing. So upon logging from here the whole page works and displays fine.
How come the references are automatically adjusted when i am logging in from this page and are not referenced when i log in from other page and route here or when i am logged out?
Global.asax code:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add("UseridRoute", new Route
(
"profile/{user}",
new CustomRouteHandler("~/UserProfile.aspx")
));
}
I am able to route my urls to an existing page. Here is how our scenario is currently working:
On Default.aspx, we have several links that link to pdf files on the server. The filenames of these files change dynamically which is why we need the url routing. When the user clicks on of the urls, the link is routed to the getFile.aspx page that has logic in it to determine which file to open.
Is there a way to have the getFile.aspx page to open in the same window as the default.aspx page?
Otherwise, I need for the getFile.aspx page to close after the intended processing is complete, and I've not been able to close it without getting the close window dialog box. I figure if it opens in the same browser window, I can redirect back to the default.aspx page when processing is finished.
Is it possible to generate hyperlinks from the contents of a folder... i.e. parses the folder takes the name of the file makes it a hyperlink (removing the .pdf, .doc. etc). I could have sworn I read something about this once, but I'm not finding it.
View 3 RepliesI am having 2 text boxes namely
Bill No. & Bill date. In my project.
Now Here I want to generate bill no. automatically in some sort of sequence.
For ex: If once user clicks on the at that time if bill no. is WS 100
Then other time it must be WS 101.
It must auto increamented.
Same is for Bill date in bill date field I want system date to be taken everytime.
When trying to generate rdp files on a web server with C#, when I try to save the rdp file it always fails with access denied. ASPNET and Network Services has full access, and even added EVERYONE as full permissions and it still won't save?
[code]...
my problem is i want to generate gropu of texboxes by clicking add button(one row of textboxes).in my application i want to generate one complaint id.one customer may give two or more complaints at a time.suppose,he give two or more pnr numbers and their status andprioirty may differs.for this complaint i need to generate one common complaint id.how it is possible..?
View 7 Replies