Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 12, 2008 11:52 AM by VinBrown
Apr 30, 2008 12:05 PM|LINK
I am new to Mvc architecture. I have the following doubts,Kindly help
1)When I debug I am able to go to home page but if I use ctrl f5 and run it I get the following error
Line 23: <li><a href="~/" runat="server">Home</a></li>
Line 24: <li><%= Html.ActionLink("About Us", "About", "Home") %></li>
Line 25: </ul>
What exactly does Html.ActionLink function do?
2) When we add controls in aspx page we cant access them in code behind. I read in one of the blogs which said by converting the page to web application in solution explorer we can access.this worked. The only difference i saw was a designer.cs file was
generated. What exactly does this file do? and how does it affect the controls visibility in code behind? And how is it different from the usual Mvc content page?
3) Mvc does not support event handling since it uses controller action method is waht I read. But I can have event handlers in my code behind. So is it right when i say event handling is not supported?
4) Viewstate and hence postback is not supported in Mvc. What exacly is the use of this?what does it achieve ? and what is the work around to it? do we have to use hyperlinks to again redirect to some action and to the analysis ourselves. how exactly can
we send data,suppose a textbox1,how do i send it from one page to the next page? I thought of query string but was unable to do so.
My controller is productcontroller and action is display do i have to say
http://Product/Display?TextBox1=TextBox1.Text This did not work.
Kindly help me out.Thanks
Apr 30, 2008 12:25 PM|LINK
1. Html.ActionLink just render a simple a-tag with the URL of your About-ControllerAction on the "Home"-Controller - the "About Us" Parameter will be seen by the user.
2. The "code behind" should (in my opinion) not be used in MVC because the controller pass the data to the view and the view only display it by using inline code or other Controlls - without using the code-behind file.
3. Of course you could use event handler - because the default view engine
is the WebForm engine - that´s why you still have a code-behind file and the page_load method - but you shouldn´t use this in MVC.
4. This is a very complex question (and there are some other threads - see here: http://forums.asp.net/p/1234762/2282096.aspx#2282096). To pass data to a view just use a form tag. Have a look at these blogposts from Scott:
May 01, 2008 06:46 AM|LINK
Thank you Mr Reman.
But could you please tell me how can i debug the error I posted? And I am not aware of Java scripts. Does the inline code mean usage of java script?
May 05, 2008 09:38 AM|LINK
cant I use anything other than list or object to send data to a view?
how can I use dataset?
can I use dataset as source and send it to view and bind it to grid?
if yes then please guide. I am unable to do so.
May 05, 2008 10:52 AM|LINK
You can use a strongly typed viewdata class to pass data from the controllers to your views. Have a look at Scotts Blogpost:
May 05, 2008 11:01 AM|LINK
Could you please guide me as to how to solve the error.
May 05, 2008 11:04 AM|LINK
And the weirdest thing is it does not give the error everytime I run it.
May 05, 2008 11:15 AM|LINK
You mean the "ActionLink" error? What error message do you get?
Have you a "Home" Controller and a "About" Actionmethod in it?
May 05, 2008 12:32 PM|LINK
You may be getting this error because of your project settings. Open up your project properties and go to the Web tab. Change the Start Action to "Start URL" and set the value to http://localhost:[your port number here]/ . The value for port number will
be the port number that the internal visual studio web server is using. This setting will have no effect on deployment. Good luck.