JavaScript - help urgent???

Asked By pardeep ravesh
03-Jul-09 07:20 AM
i have a html  table and i m adding rows dynamically on add button click using javascript
like:

name        age          salary
textbox     textbox    textbox(on add button click)
textbox     textbox    textbox(on add button click)
textbox     textbox    textbox(on add button click)

there is also a delete button for each row to delete that row

final i have a submit button

what i want when i submit all data is saved to database(sqlserver)


Re  Re

03-Jul-09 07:29 AM
Do you want at client side or
server side.

hi murali  hi murali

03-Jul-09 07:31 AM
i want it on server side

Re  Re

03-Jul-09 07:39 AM
Is it runat server textbox control?
  Vasanthakumar D replied to pardeep ravesh
03-Jul-09 07:40 AM

Hi,

the controls you have added will lost on postback.

so, you have to maintain all values of the dynamic cotnrols in hidden filed. and get the values from hidden filed. this is a painful one..

I suggest you to create controls on server side, if you dont want postback, use ajax update panel.

hi murali  hi murali
03-Jul-09 07:42 AM
no they are not runat server controls
they are html input controls
Re  Re
03-Jul-09 07:56 AM
Hi,

If you are not provide the input control as runat server u cannot get thouse values at serverside.
Take one Hidden filed set runat server.
Assign the all the values to Hiddden field at client side click of submit.
Ex:

hdn.value = txtName1.Value +":" TxtAge1.value +":" txtSalary1.value +"||";
hdn.value += txtName2.Value +":" TxtAge2.value +":" txtSalary2.value +"||";
hdn.value += txtName3.Value +":" TxtAge3.value +":" txtSalary3.value +"||";
hdn.value += txtName4.Value +":" TxtAge4.value +":" txtSalary4.value +"||";

In code behind:
string[] fistSplit=hdn.value.split('||');
foreach(string str in firstSplit)
{
string[] secondsplit= str.split(':');
// then implement u r sql qry.
}
check this  check this
03-Jul-09 08:05 AM
hi,

try with javascript. pass the values as query string to another page. there you do code behind operations.

check the below code

<script language='javascript'>

function frmSubmit()
{

 txt1 = document.getElementById("txt1").value
 txt2 = document.getElementById("txt2").value
 txt3 = document.getElementById("txt3").value

 location.href="NextPage.aspx?Txt1=" + txt1 + "&Txt2=" + txt2 +"&Txt3=" + txt3

}
</script>

<input type="button" onclick="frmSubmit();" value="Submit">


read the query string values in the "NextPage.aspx" and process the values

Html Control In Server Side Code.....  Html Control In Server Side Code.....
03-Jul-09 08:42 AM

Hi,

To get values from Html control in Server Side code , then use the following

protected void buttonSubmit_Click(object sender, EventArgs e) {

string strUsername = Request.Form["textBoxUsername"];

string strPassword = Request.Form["textBoxPassword"];

Response.Write("Username = " + strUsername + "<br />" + "Password = " + strPassword);

 

// write ur database adding code here..

}

 

Thanks

R.E

hi murali  hi murali
05-Jul-09 01:40 AM
hdn.value = txtName1.Value +":" TxtAge1.value +":" txtSalary1.value +"||";
hdn.value += txtName2.Value +":" TxtAge2.value +":" txtSalary2.value +"||";
hdn.value += txtName3.Value +":" TxtAge3.value +":" txtSalary3.value +"||";
hdn.value += txtName4.Value +":" TxtAge4.value +":" txtSalary4.value +"||";
 
it is not necessary dat there are 4 rows as rows are dynamically added and on submit click whole data is loast
re  re
06-Jul-09 04:58 AM
You have to mainten viewstate across the postback.
set Runat=server and viewstateEnable= true;
Or:
Ofter submit the control once again you have to split the hdnvalue values and assign to thouse values to textboxes.
Create New Account
help
javascript in user control. .NET Framework Hi all, i am having one user control. what i want is to add javascript which will gets called on button click of user control. but user control is not working if i add javascript in user control. . but if i add javascript in page in which i am adding user control then
How to find control with JavaScript .NET Framework I have a ASP.NET page this page has a Tab Control Tabl Control has several tabs Each tab has a custom UserControl Each UserControl has several ASP.NET side. My question is: While on Tab 1 how do I find an ASP.NET control which is located on different Tab and UsercControl using JavaScript? Thank You Peter ASP.NET Discussions TextBox1.ClientID (1) TextBox2.ClientID (1) Button1.ClientID (1 Mar 2009 14:48:49 -0600, "Peter" <czupet@nospam.nospam> Do some research on the control type's ClientId property. If you wanted to put the focus on Button1using dynamically generated javascript the server code might write regards A.G. What about if I am not using
access hidden control in javascript giving error Hi, I am using a listview control and in this listview control i am using a image, hidden field and button control. when i click on button then its imageid i want to use in javascript so i am accessing its imageid through hidden control in javascript like this var fid = document.getElementById('<% = Listview1.FindControl("HiddenPid").ClientID%> ').value; alert(fid); but there
how to restrict popup calendar control in javascript for 1 month how to restrict popup calendar control in javascript for 3 months i have the javascript calender and i need to restrict that calendar it should show only for 1 months For a specific code sample, you will have to tell us what kind of a Javascript Calendar you are using & how it manages navigating between months - with hyperlinks or through a box. Following is the process for controlling a date range for the ASP.NET Calendar control and you adapt the same for your Javascript Calendar. To restrict a Calendar control (System.Web.UI.WebControls.Calendar) to a specified range
how to restrict popup calendar control in javascript for 3 months how to restrict popup calendar control in javascript for 3 months hi i have a jscript calender how to restrict the months onlt for 3 months It depends upon what javascript code u used for calender, there are put the actuall restriction what u wnat. function 0'> "; table = table + "<tr class = 'header'> "; table = table + " <td colspan = '2' class = 'previous'> <a href = 'javascript:changeCalendarControlMonth(-1);'> &lt;< / a> <a href = 'javascript:changeCalendarControlYear(-1);'> &laquo;< / a> < / td> "; table = table + " <td colspan = '3' class = 'title'> " + months[currentMonth-1 br> " + currentYear + "< / td> "; table = table + " <td colspan = '2' class = 'next'> <a href = 'javascript:changeCalendarControlYear(1);'> &raquo;< / a> <a href = 'javascript:changeCalendarControlMonth(1);'> &gt;< / a> < / td> "; table = table + "< / tr