Click here to Skip to main content
15,888,089 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: MVC 3 Areas for code organization giving headaches Pin
eddieangel5-Oct-11 11:04
eddieangel5-Oct-11 11:04 
GeneralRe: MVC 3 Areas for code organization giving headaches Pin
imak6-Oct-11 8:27
imak6-Oct-11 8:27 
GeneralRe: MVC 3 Areas for code organization giving headaches Pin
eddieangel6-Oct-11 8:31
eddieangel6-Oct-11 8:31 
QuestionStarting Carrier Pin
Nickk Bisht5-Oct-11 2:52
Nickk Bisht5-Oct-11 2:52 
AnswerRe: Starting Carrier Pin
Richard MacCutchan5-Oct-11 9:39
mveRichard MacCutchan5-Oct-11 9:39 
AnswerRe: Starting Carrier Pin
JP_Rocks6-Oct-11 1:08
JP_Rocks6-Oct-11 1:08 
AnswerRe: Starting Carrier PinPopular
Dalek Dave6-Oct-11 22:28
professionalDalek Dave6-Oct-11 22:28 
QuestionASP.NET Routing Pin
Dominick Marciano4-Oct-11 14:46
professionalDominick Marciano4-Oct-11 14:46 
I'm currently programming on ASP.NET 3.5 and started learning about URL routing. I found an article on it here. I went through it and tried to implement it in my site but came across an issue that I can't figure out.

I'm trying to use this for a web store. Right now to see a products details the user would need to go to an address such as /Shopping/ProductDetails.aspx?productID=XXX where 'XXX' is the product GUID from the database. I wanted to make it simpler so a customer could go to /Products/Computer250 and it would bring up a specific product.

I got the routing to work where it would redirect to the correct product page. However on the product details page I have a form view with controls it is to display information like price, description, In Stock/Backordered, etc. After the products information is loaded from the database, I use the following code to set the In Stock/Backordered label:

VB
Dim totalStock As Integer = CInt(ds.Tables(0).Rows(0).Item("TotalStock"))
Dim StockLabel As Label = DirectCast(fvProduct.FindControl("lblStock"), Label)
        If totalStock > 0 Then
            StockLabel.Text = "In Stock"
            StockLabel.ForeColor = Drawing.Color.Green
        Else
            StockLabel.Text = "Backordered"
            StockLabel.ForeColor = Drawing.Color.Red
        End If


Now this code work's fine if the customer got to the product's details page if they clicked on a link with the products GUID. When they arrive at the product's details page because of the URL routing, the StockLabel object is nothing and this causes a error.

Why does fvProduct.FindControl return the correct label when the user follows a direct link but when the user gets to the page based on URL routing the fvProduct.FindControl returns nothing?

Any help would be greatly appreciated as I haven't been able to figure this out, or find an answer online. Thanks in advanced for any help you can provide.
AnswerRe: ASP.NET Routing Pin
Parwej Ahamad4-Oct-11 17:54
professionalParwej Ahamad4-Oct-11 17:54 
GeneralRe: ASP.NET Routing Pin
Dominick Marciano5-Oct-11 11:08
professionalDominick Marciano5-Oct-11 11:08 
GeneralRe: ASP.NET Routing Pin
Parwej Ahamad5-Oct-11 19:13
professionalParwej Ahamad5-Oct-11 19:13 
GeneralRe: ASP.NET Routing Pin
Dominick Marciano6-Oct-11 14:26
professionalDominick Marciano6-Oct-11 14:26 
GeneralRe: ASP.NET Routing Pin
Parwej Ahamad6-Oct-11 18:26
professionalParwej Ahamad6-Oct-11 18:26 
GeneralRe: ASP.NET Routing Pin
Dominick Marciano7-Oct-11 16:21
professionalDominick Marciano7-Oct-11 16:21 
QuestionAsp.net and uploading large files Pin
Ahmad Safwat4-Oct-11 14:30
Ahmad Safwat4-Oct-11 14:30 
AnswerRe: Asp.net and uploading large files Pin
uspatel4-Oct-11 21:31
professionaluspatel4-Oct-11 21:31 
GeneralRe: Asp.net and uploading large files Pin
Ahmad Safwat5-Oct-11 2:55
Ahmad Safwat5-Oct-11 2:55 
AnswerRe: Asp.net and uploading large files Pin
Ravindra Bisen5-Oct-11 6:41
Ravindra Bisen5-Oct-11 6:41 
GeneralRe: Asp.net and uploading large files Pin
Ahmad Safwat5-Oct-11 11:28
Ahmad Safwat5-Oct-11 11:28 
Questionload , change and save xml file as appropriate encoding Pin
oujeboland4-Oct-11 13:02
oujeboland4-Oct-11 13:02 
Question"Microsoft JScript runtime error: Object expected" using Telerik MVC controls Pin
jboyd1114-Oct-11 5:54
jboyd1114-Oct-11 5:54 
QuestionSet the NavigateUrl of a ImageMap in Repeater Pin
Farhad Eft3-Oct-11 23:53
Farhad Eft3-Oct-11 23:53 
AnswerRe: Set the NavigateUrl of a ImageMap in Repeater Pin
Parwej Ahamad4-Oct-11 12:01
professionalParwej Ahamad4-Oct-11 12:01 
QuestionTCP/IP Client Server Chat Application in ASP.Net Pin
nitin_ion3-Oct-11 23:11
nitin_ion3-Oct-11 23:11 
AnswerRe: TCP/IP Client Server Chat Application in ASP.Net Pin
Parwej Ahamad4-Oct-11 12:06
professionalParwej Ahamad4-Oct-11 12:06 

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.