How to access HTML controls created at runtime by client side jscript?

I have a webform that uses some javascript to add extra tablerows, cells, and some HTML input controls like radios and checkboxes.

Is there a way for the code behind files to access these dynamically created HTML controls once the page is posted back to the server?

Right now i am finding the controls created client side are not being rendered back on the server.

0
jimmy
11/15/2006 2:13:46 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

6 Replies
667 Views

Similar Articles

[PageSpeed] 29

add runat="server" on those controls
Cheers
Al
My Blog
MapStats.NET
Please click on 'Mark as Answer' if this post answered your question!
0
albertpascual
11/15/2006 2:40:56 AM

Hi Jimmy,

That's a tough one. It would be possible but only with some significant development. An example would be a custom server control with an Item Template of some description that it consumed on postback in order to "create" the child controls for itself based on a Javascript derived XML input (property) or other.

I could see this being a real mare, and while most things are possible with the appropriate amount of effort, it may not be a valuable excercise.

A much better approach, would be to use ATLAS or Out of Band Postback in a custom server control to create the controls within the page using server side code. Using either of these techniques would not lead to the full page cycle postback and would leave the user with very mmuch the same experience as the simple Javascript solution.

Regards,

Martin.


Rgds,
Martin.

For the benefit of all users please mark any post answers as appropriate.
0
mokeefe
11/15/2006 3:29:38 AM

albertpascual:
add runat="server" on those controls

 

That would not work because these HTML controls are not created at design time.

0
jimmy
11/15/2006 3:46:42 AM
mokeefe:

Hi Jimmy,

That's a tough one. It would be possible but only with some significant development. An example would be a custom server control with an Item Template of some description that it consumed on postback in order to "create" the child controls for itself based on a Javascript derived XML input (property) or other.

I could see this being a real mare, and while most things are possible with the appropriate amount of effort, it may not be a valuable excercise.

A much better approach, would be to use ATLAS or Out of Band Postback in a custom server control to create the controls within the page using server side code. Using either of these techniques would not lead to the full page cycle postback and would leave the user with very mmuch the same experience as the simple Javascript solution.

Regards,

 

Thanks for the suggestion.

The only way i can think of is saving the XML representation of the dynamically created controls into a string, and saving it to a hidden form field and let the server parse the XML to reconstruct the controls and their values.

Kind of messy, but i am out of ideas.

Martin.

0
jimmy
11/15/2006 3:49:15 AM

jimmy q:
mokeefe:
  The only way i can think of is saving the XML representation of the dynamically created controls into a string, and saving it to a hidden form field and let the server parse the XML to reconstruct the controls and their values.

Who would think English was my first language! Thats' precisely what I was at trying to say.

Good luck with it.

Martin.


Rgds,
Martin.

For the benefit of all users please mark any post answers as appropriate.
0
mokeefe
11/15/2006 4:19:03 AM

jimmy q:
mokeefe:
  The only way i can think of is saving the XML representation of the dynamically created controls into a string, and saving it to a hidden form field and let the server parse the XML to reconstruct the controls and their values.

Who would think English was my first language! Thats' precisely what I was trying to say.

Good luck with it.

Martin.


Rgds,
Martin.

For the benefit of all users please mark any post answers as appropriate.
0
mokeefe
11/15/2006 4:19:24 AM
Reply:

Similar Artilces:

How to access dynamically Html controls (client side controls) using C# server side scripts
Folks,I have problem try to to access dynamically Html controls (client side controls) using C# server side scripts. Please give me helps.     The error is as follows Exception Details: System.InvalidCastException: Specified cast is not valid.Source Error: Line 79: { Line 80: Control c = Page.FindControl("ddlTC" + i); Line 81: ((DropDownList)c).DataSource = mdt; Line 82: ((DropDownList)c).DataTextField = "ClassID"; Line 83: ((DropDownList)c).DataValueField = "Course"; My aspx page source codes: ...<...

Accessing dynamically created client-side controls via Request.Form.GetValues
Hi all, am trying to retrieve the values of a set of dynamically created client-side controls via Request.Form.GetValues ... is it possible? cuz am getting a NullReferenceException When i execute Request.Form.GetValues("textBox") , and if it's impossible can i get an alternative? Like: ....... var newRow = document.getElementById("table1").insertRow(); var newCell = document.createElement("TD"); newCell.innerHTML = "<input type='text' id='newText' value='blabla'>"; newRow.appendChild(newCell) .........

Access web form content from client side HTML file using javascript
I have two browser windows open, one an html file residing on the client and one an aspx page served up by the web server. Neither window is related to the other; neither one opened the other. Is it possible for javascript on the html file which resides on the user's local computer to "read" any of the information from the other open window? Ideally, I'd like to read a hidden input field from the web page. The solution only has to work in IE 6 and 7. Thanks in advance. Man, this sounds more like a virus, like spyware... Why do you need to do such thing? What I want is to open ne...

How to access the properties and methods of the ActiveX control on the client side in Web Form using javascript or vbscript
Hi All, I have looked almost every where for this, and I'll be really appreciated if someone can help me with this. I found a article in MS KB article, #317392, but it is not extactly what I wanted. How do you reference an ActiveX control's methods and properties with javascript in the ASPX? Following is what I have. Some how the following line in the btnclick() does not seems to be working. AlarmCtl.StartTimer() I have done this with just .HTML and it works just fine. Can any one help. Thanks in advance. //===========================...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

How to Access/Pass Server Side Array Variable at Another Web Form's Client Side
Hi All,I struck up with some intrested senario at my application development...hope some body will guide me or sends me some code snippets....Thanks in advance.Senario is like this.....in A.aspx (using C# .net 2.0 as code behind) I am going to have a array variable basically it is an TWO Dimensional array after populating the values in array I need to redirect/ reload another web form B.aspx, here i need to access the array in B.aspx client side JavaScript.How can I do this...Thanks AgainRaju Dont do a redirect but use server.transfer. That way the previous page will still hold its value, ...

I'm having a problem with creating dynamic control (dropdown) on client side & accessing that control on code behind.
Hi Team, In page load default I’m showing "start time" dropdown,” End time" dropdown. I'm giving one checkbox option to user, if user checks I’m enabling the button. On that button click, I want to create client side dynamic controls for adding on start time, end time. Start Time with 3 dropdown Hours, Mint, Unit (AM, PM). End Time with 3 dropdown Hours, Mint, Unit (AM, PM). This scenario is for measuring "SAMPLE “multiple start time, end time. I want to calculate the duration of start, end time & show to user. Can any one give me the idea or ...

Is there a correspondance for each server side control to be equivalent to a client side html control
Where can find the list and can use that equivalence and what is its usage plsThanksThanks a lot, I appreciate your taking the time to help me. What exactly do you mean? A correspondence of what?All controls have a ClientID property, which for most controls tells the DOM element ID that will be used in the HTML rendering. Aside from that certain controls might offer additional client-side functionality, but there's no one standard.Thanks,EilonBlog: http://weblogs.asp.net/LeftSlipper/ I mean. When I am using html control in my aspx page like:  <input type=text ..>  and...

web forms with client and server side controls??
Hi, I have a form that has client and server side controls. I have a problem in that any client controls (textbox) within the form runat="server" can not be accessed with client side code. Anyone got any ideas why and what work arounds are possible. Regards, Graham. once a form element is inside a <FORM> tag, you can no longer refer to it by its ID alone. you have to refer to it by formname.elementid or document.all.elementid. use document.getElementById(yourtextboxid) to get a ref to the element in the form. using this allows u to bypass the formn...

dynamically creating html controls on web form
hello all, I'm creating html <input type="file" name="test" id="test" runat="server"> dynamically using Javascript on a .aspx page. when i submit the form i get Javascript "Access is denied" error. if i take out name attribute from input tag in javascript -  it is not throwing any javascript error but the file is not being uploaded to the server. Can anyone point me in the right direction? Thanx in advance     Maybe this is a security restriction imposed by the browser? I know there are several constrain...

Creating and accessing at runtime created controls
Hello,For a website I am creating I need to create textboxes at runtime depending from the value inserted in a textbox, when the number is entered there should be created a table (or something alike) with x rows each having for example 4 textboxes. I managed to create a table with the textboxes but I cannot address them from my code behind (C#). I have allready tried it 2 ways...The first was using literal controls, but the alignment wouldnt work... 1 PlaceHolder ph = new PlaceHolder();2 LiteralControl openrij = new LiteralControl("&lt;tr><td>");3 ...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

Access value of dynamically created control(thru JScript) in .net page
Hi  Using  JS code I have dynamically created some HTML controls to  asp.net page. I am not able to set runat=server for them. As a result am not able to access their value. I assume because this property is not set, am not getting the values.  If anyone can help me with the problem, pls post their answers. I need it urgently.      runat=server is only for conrols that are rendered by the serverside code and not by the client. runat=server means nothing to the client.If you want to reference the values, you need to use Request.Form like you would...

Web resources about - How to access HTML controls created at runtime by client side jscript? - asp.net.web-forms

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

New online tool in cane toad control
A free mapping service could help invested groups work towards more targeted control methods for cane toads in Queensland.

Sandy Bay blaze under control
A FIRE at a property in Sandy Bay has been brought under control, a witness says.

Robots to bring down 87-metre tall Sydney Harbour Control Tower
It's been called a &quot;hypodermic in God's bum&quot; and a &quot;concrete mushroom&quot;. And soon it will be gone.

Let Aboriginal people take control of their destiny
Australia will move forward when it cedes power to Indigenous people and demands accountability.

Beyond Biglaw: 3 Quality Control Tips For Firms
... fierce, and enhanced by the expressed the desire of many corporate clients to keep as much work as possible in-house, a focus on quality control ...

Honda recalls Accord to replace airbag control unit
... , Safety , Sedan Honda will recall the 2008-2010 Accord sedan because moisture can corrode the supplemental restraint system electronic control ...

Central banks tried to control world, failed - Business Insider Deutschland
"The most infuriating thing is that central banks think they control the world, and in reality they've failed miserably at it."

Apple TV expanding voice controls
The latest beta version of Apple TV's upcoming software also includes support for Bluetooth keyboards and the ability to organize your apps into ...

BrandPost: Data is the New Control Point
As consumers, we are now used to having an app for everything. Apps are easy to develop, easy to deploy, and easy to change. Apps are modular ...

Resources last updated: 2/10/2016 3:21:13 AM