putting code behind onto client side ascx, aspx pages
-
I am using the asp.net mvc framework and like it so far, however there are times that I need to use a code behind page. mainly for my gridview events and such. MVC does not use or recommend using code behind pages. So my question is, how would I put the events for my gridview, or any code that is in my code behine, in my usercontrol and aspx pages? Would it be as simple as this: UserControl sample:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" > <%@ Register Src="PopUpBox.ascx" TagName="PopUpBox" TagPrefix="uc1" > <br> void page_load(Object sender, EventArgs args)<br> { }
if so, what is going to keep these events in order if my user control is apart of a page that has it's own page_load or other events? Would my gridview events be a mere copy and paste from code behind to the script area? Sorry if this is a basic question, web development has never really been my main development. Thanks for the help. -
I am using the asp.net mvc framework and like it so far, however there are times that I need to use a code behind page. mainly for my gridview events and such. MVC does not use or recommend using code behind pages. So my question is, how would I put the events for my gridview, or any code that is in my code behine, in my usercontrol and aspx pages? Would it be as simple as this: UserControl sample:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" > <%@ Register Src="PopUpBox.ascx" TagName="PopUpBox" TagPrefix="uc1" > <br> void page_load(Object sender, EventArgs args)<br> { }
if so, what is going to keep these events in order if my user control is apart of a page that has it's own page_load or other events? Would my gridview events be a mere copy and paste from code behind to the script area? Sorry if this is a basic question, web development has never really been my main development. Thanks for the help.MVC does not include code-behind for a good reason; asking to use it violates the concepts and principles of the pattern. What events are you trying to use?
I know the language. I've read a book. - _Madmatt
-
MVC does not include code-behind for a good reason; asking to use it violates the concepts and principles of the pattern. What events are you trying to use?
I know the language. I've read a book. - _Madmatt
I agree, which is why I need to put what code I was going to use in code behind, in my usercontrol and aspx pages. The code right now that I need to use:
void Page_Load(object sender, EventArgs e) { } void GridView1_SelectedIndexChanged(object sender, EventArgs e) { } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { } And possibly RowCreated event.
Right now it is just this. Some of my code I could move to the Controller and also most can be handled in the Model itself, but events like this I am not sure what to do with. Thanks for the time. -
I agree, which is why I need to put what code I was going to use in code behind, in my usercontrol and aspx pages. The code right now that I need to use:
void Page_Load(object sender, EventArgs e) { } void GridView1_SelectedIndexChanged(object sender, EventArgs e) { } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { } And possibly RowCreated event.
Right now it is just this. Some of my code I could move to the Controller and also most can be handled in the Model itself, but events like this I am not sure what to do with. Thanks for the time.There is essential no need to handle these events with code-behind, or code-in front RowCreated is already being done as the view is being rendered The other events can be handled with JavaScript or by the controller. SelectedIndexChanged I can see being handled with JavaScript.
I know the language. I've read a book. - _Madmatt
-
There is essential no need to handle these events with code-behind, or code-in front RowCreated is already being done as the view is being rendered The other events can be handled with JavaScript or by the controller. SelectedIndexChanged I can see being handled with JavaScript.
I know the language. I've read a book. - _Madmatt
I understand rowcreated is already being created for me, but there are a few columns that I need to check the value of each time it is created and modify it if needed. RowCreated is generally where this would be done. I will look for some grid events that can be handled by javascript. I wasn't aware this could be done. Thanks again for the time and help.
-
I understand rowcreated is already being created for me, but there are a few columns that I need to check the value of each time it is created and modify it if needed. RowCreated is generally where this would be done. I will look for some grid events that can be handled by javascript. I wasn't aware this could be done. Thanks again for the time and help.
-