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