473,699 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to send data to the server from dynamically created html controls

7 New Member
Hii,

currently i am working on an apliction(ASP.N ET/C#) that creates dynamic html rows which contain six html text boxes and a html dropdowllist. At the time of page load the web page contain six server side text boxes and a serverside drop down list. and a html "Addrow" buton which create client side textboxes and dropdown list dynamichally Now i am meeting a problem of passing values from dynamichally created html controls to Server Side
Very Urgent
please help me
code follows

[HTML]<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script type="text/javascript" language="javas cript">


var ar=new Array();
var ar2=new Array();
var len;
function LoadDdl()
{
debugger;
if(document.get ElementById('Se lect1')!=null)
{
len=document.ge tElementById('S elect1').option s.length;

for(i=0;i<len;i ++)
{

ar[i]=document.getEl ementById('Sele ct1').options[i].innerHTML;
ar2[i]=document.getEl ementById('Sele ct1').options[i].value;
}
}
}

function addRow()
{
var ni = document.getEle mentById('trCon tent');
var numi = document.getEle mentById('theVa lue');
var num = (document.getEl ementById('theV alue').value -1)+ 2;
numi.value = num;
//add a row to the rows collection and get a reference to the newly added row
var newRow = document.all("t blGrid").insert Row();

//add 7 cells (<td>) to the new row and set the innerHTML to contain text boxes

var oCell = newRow.insertCe ll();
oCell.innerHTML = "<input type='text' id="+"slno"+num +" name='t1' style='width: 72px'>";


oCell = newRow.insertCe ll();
//oCell.innerHTML = "<input type='text' name='t2' style='width: 72px'>";
//oCell.innerHTML = "<select id='ddl' name='t2' style='width: 72px'>";
var selecttg="<sele ct id="+"ddl"+num+ "' style='width:72 px'>";
var optiontg="";
for(i=0;i<len;i ++)
{

//var sel=document.ge tElementById('d dl');
var optiontg =optiontg+"<opt ion value="+ar2[i].toString()+">" +ar[i].toString()+"</option>";

}
var fullbotle=selec ttg+optiontg;
oCell.innerHTML =fullbotle+"</select>";
//oCell.innerHTML ="</select>";
oCell = newRow.insertCe ll();
oCell.innerHTML = "<input type='text' id="+"number"+n um+" name='t3' style='width: 72px'>" ;
oCell = newRow.insertCe ll();
oCell.innerHTML = "<input type='text' id="+"qty"+num+ " name='t4' style='width: 72px'>";

oCell = newRow.insertCe ll();
oCell.innerHTML = "<input type='text' id="+"rate"+num +" name='t5' style='width: 72px'>";

oCell = newRow.insertCe ll();
oCell.innerHTML = "<input type='text' id="+"discount" +num+" name='t6' style='width: 72px'>";
oCell = newRow.insertCe ll();
oCell.innerHTML = "<input type='text' id="+"Amount"+n um+" name='t7' style='width: 72px'>";
oCell = newRow.insertCe ll();
oCell.innerHTML = "<input type='button' value='Delete' onclick='remove Row(this);'/>";
}

//deletes the specified row from the table
function removeRow(src)
{
/* src refers to the input button that was clicked.
to get a reference to the containing <tr> element,
get the parent of the parent (in this case case <tr>)
*/
var oRow = src.parentEleme nt.parentElemen t;

//once the row reference is obtained, delete it passing in its rowIndex
document.all("t blGrid").delete Row(oRow.rowInd ex);
}
</script>
</head>
<body onmouseover="Lo adDdl()">
<input type="hidden" value="0" id="theValue" />
<form id="form1" runat="server">
<div>
<table id="tblGrid" style="table-layout:fixed" runat="server">
<tr>
<td >
SLNo</td>
<td >
Item</td>
<td >
Number</td>
<td >
Quantity</td>
<td >
Rate</td>
<td >
Discount</td>
<td>
Amount</td>
</tr>
<tr id="trContent" >
<td >
<input id="Text1" type="text" runat="server" style="width: 84px" /></td>
<td >
<select id="Select1" runat="server" style="width: 102px"></select></td>
<td >
<input id="Text3" type="text" runat="server" style="width: 72px" /></td>
<td >
<input id="Text4" type="text" runat="server" style="width: 66px" /></td>
<td >
<input id="Text5" type="text" runat="server" style="width: 66px" /></td>
<td >
<input id="Text6" type="text" runat="server" style="width: 66px" /></td>
<td>
<input id="Text7" type="text" runat="server" style="width: 72px" /></td> <td ><input type="button" value="Delete" onclick="remove Row(this);" /></td>
</tr>

</table>
<hr/>
<input type="button" value="Add Row" onclick="addRow ();" />
<asp:Button ID="Button1" runat="server" OnClick="Button 1_Click" Text="Save" /></div>
</form>
</body>
</html>
[/HTML]
Thanking you and regards
Balu
Apr 2 '08 #1
3 2998
acoder
16,027 Recognized Expert Moderator MVP
As long as you've named your elements and appended them within the form, the values should be submitted when you submit the form.
Apr 2 '08 #2
balurajeev
7 New Member
can u pls give an example using dynamic contol
Apr 2 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Does none of the data from the dynamically created elements get sent when the form is submitted or only some of the data?
Apr 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
6550
by: Russ | last post by:
I'm interested in setting up a web page where live data can be displayed in real-time on the web page. For example: I would like to display a (nice looking) graph of some data value versus time and have the graph update every second without the user having to do anything like hit a refresh button. The data to plot is readily available from an application running on the server - I can expose it in whatever way is needed (currently easily...
9
3149
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the other page, or is there something else like a stream which will be like a file. I am attempting to get a way from writing out a file and then having to give the page that I am posting to the file name. Instead I would like to just from asp.net...
0
1872
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to collect the data in the Textboxes which i added dynamically from server side, i am not able to do . Alos i tried to bedug, the total no of rows in Html table does not reflect the dynamically added rows.
7
6383
by: Tom wilson | last post by:
I'm trying to create dynamic controls in ASP.Net. It's driving me nuts. I keep getting the error: Control '16' of type 'RadioButton' must be placed inside a form tag with runat=server. Dim Place1 As New PlaceHolder Controls.Add(Place1) For y = 1 To Choices.RecordCount Choices.MoveTo(y)
3
3767
by: Ferryandi | last post by:
hi, i have created a button link like this and attach it to placeholder in code behind linkbutton1 = New LinkButton linkbutton1.Text = "Link Button linkbutton1.ID = "Link1" PlaceHolderLink.Controls.Add(linkbutton1) but how do i add runat="server" as in html code in code behind, im using vb.net
4
2713
by: assgar | last post by:
Hi I am stuck on a problem. I use 3 scripts(form, function and process). Development on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply.
3
3525
by: pbd22 | last post by:
Hi. How do I add the runat=server attribute on a buttonfield link dynamically? thanks!
4
4756
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example to demonstrate my issues. Lets say I have a WebForm with a DropDownList where the user selects a number from 1 to 10 (the DropDownList is not dynamically created). I also have a button on there that I use to trigger a PostBack. Based on the...
1
4899
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.