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. dynamic controls and request objects

dynamic controls and request objects

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestion
3 Posts 3 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.
  • H Offline
    H Offline
    Harikrk
    wrote on last edited by
    #1

    In my page i am creating a set of controls dynamically for adding attributes for a product. Initially it will show a add attribute button. On clicking that first set of textbox to enter attributes will be shown. Also a add more button will be showing . On clicking the addmore button another set of textbox will be added to the pane keeping the first one there. I have handled the code in the page event to keep the first one when adding the new one. This will check the request object contains the attribute field and if present it will be added first. if (Request["ctl00$ContentPlaceHolder1$TxtAttribName" + i] != null) { add the requested content with same name. } I am getting this worked fine. But some times when the response from server is slow i am not getting the first one which are added from request object Do anyone can help me in this?

    N A 2 Replies Last reply
    0
    • H Harikrk

      In my page i am creating a set of controls dynamically for adding attributes for a product. Initially it will show a add attribute button. On clicking that first set of textbox to enter attributes will be shown. Also a add more button will be showing . On clicking the addmore button another set of textbox will be added to the pane keeping the first one there. I have handled the code in the page event to keep the first one when adding the new one. This will check the request object contains the attribute field and if present it will be added first. if (Request["ctl00$ContentPlaceHolder1$TxtAttribName" + i] != null) { add the requested content with same name. } I am getting this worked fine. But some times when the response from server is slow i am not getting the first one which are added from request object Do anyone can help me in this?

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Harikrk wrote:

      if (Request["ctl00$ContentPlaceHolder1$TxtAttribName" + i] != null) { add the requested content with same name. }

      This is not a good method. You will end up with viewstate issues. I suggest to use GridView/DataGrid with textboxes placed on template columns. When "Add more" button is clicked, add new rows to the grid's datasource and rebind grid. This makes the process easy and ASP.NET manages viewstate for the dynamically created textboxes along with the parent control (GridView/DataGrid).

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      1 Reply Last reply
      0
      • H Harikrk

        In my page i am creating a set of controls dynamically for adding attributes for a product. Initially it will show a add attribute button. On clicking that first set of textbox to enter attributes will be shown. Also a add more button will be showing . On clicking the addmore button another set of textbox will be added to the pane keeping the first one there. I have handled the code in the page event to keep the first one when adding the new one. This will check the request object contains the attribute field and if present it will be added first. if (Request["ctl00$ContentPlaceHolder1$TxtAttribName" + i] != null) { add the requested content with same name. } I am getting this worked fine. But some times when the response from server is slow i am not getting the first one which are added from request object Do anyone can help me in this?

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        yaah N a v a n e e t h is right.. the controls dynamically created will be stateless... and also u have hardcoded the client id ... which may cause you problems if you change the id of masterpage or use dynamic masterpages... in future.. Using Grid instead will solve your problems.and also easier to handle

        Abhishek Sur

        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