I'm attempting to merge two projects in visual studios 2008
The project I am trying to bring in is styled like the old school asp.net projects using the code behind setups to access the on page load methods and so on, but the other projects is the new fangled MVC3 styled project.
Now I am fully aware that these two projects are mapped differently for access and most likely shouldn't be put together, but if i listened to every thing i was told not to do, i wouldn't have the bad ass tattoo of an angel eating a hot dog on my left ass cheek.
Now when I talk about merging these two together all I'm really talking about is bring in 1 view of .aspx type into my MVC3 project and making it run along side the other views that are there. I have been able to bring it in, I have a function in a controller setup for it and I have it's code behind there linked in properly, every thing seems to be a go, but intellisense doesn't recognize that the html tags that have an id and a runat server property on them are going to be objects in my code behind. It keeps telling me to declare these variables.
For shits and giggles I did try declaring them, at which point intellisense smiled and gave me a wink before dashing my hopes against a sharp rock by alerting me that the variables had all ready been declared when the page was parsed.
Edit: The controller is performing it's own tasks, as I stated above the code behind is handling the page load function and in the old setup the you could directly access any html tags that used the runat server propertie, I'm trying to duplicate this along side MVC3, I'm not trying to put it all in the controller. So to clear it up, I have a Model, View, controller, then inside my view i have my aspx page with a code page named filename.aspx.cs, does that help?
Edit2: OK for this setup like i said above were using vs2008 so it has the view model and controller folders where you place your three separate areas I have a particular view from another project that was using the old code behind approach of attaching a code file to a .aspx file by using the CodeBehind="Default.aspx.cs" parameter, so I pulled this .aspx file with it's code behind file from the old project and stuck it into the new MVC3 project and told them to coexist much like a an adult tells a child not to stick something in there mouth(just cause you tell em to doesn't mean there gonna). but the old code behind file uses a page load function that has to initialize some html tags from a certain library but i of course can't access these tags, and they don't have html helpers or any thing cool like that.
Any help would be greatly appreciated.
I found the solution, all i needed to do to access these tags was use the FindControl() function, in side the code behind file, it was that simple, the thing runs like a champ now. So what i had was a view with a control like
<button id="foo" runat="server">
then of course i had a controller with the function
public ActionResult Index()
{
Return View();
}
and lastly I have the code behind which contains
protected void Page_Load(object sender, EventArgs e)
{
((Button)This.FindControl("foo")).DoSomething();
}
Easy peasy lemon squeezy.
thanks for the help any way guys