Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. putting code behind onto client side ascx, aspx pages

putting code behind onto client side ascx, aspx pages

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-nettoolsarchitecture
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DeepToot
    wrote on last edited by
    #1

    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.

    N 1 Reply Last reply
    0
    • D DeepToot

      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.

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • N Not Active

        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

        D Offline
        D Offline
        DeepToot
        wrote on last edited by
        #3

        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.

        N 1 Reply Last reply
        0
        • D DeepToot

          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.

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          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

          D 1 Reply Last reply
          0
          • N Not Active

            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

            D Offline
            D Offline
            DeepToot
            wrote on last edited by
            #5

            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.

            N 1 Reply Last reply
            0
            • D DeepToot

              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.

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              I would evaluate the need for using a GridView control. These [^]links may provide some guidance.


              I know the language. I've read a book. - _Madmatt

              D 1 Reply Last reply
              0
              • N Not Active

                I would evaluate the need for using a GridView control. These [^]links may provide some guidance.


                I know the language. I've read a book. - _Madmatt

                D Offline
                D Offline
                DeepToot
                wrote on last edited by
                #7

                Great idea, thank you for the link - seems like something I can use.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups