View Single Post
  #3 (permalink)  
Old April 14th, 2008, 05:11 AM
vinod_yadav1919 vinod_yadav1919 is offline
Friend of Wrox
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919

Hi Peter!!
I am able to figure it out but still thinking abt it!!

<input type="text" id="activeCategory" value="0" />
<input type="button" onclick="addMoreRows()" id="myBtn" value="AddMore" />

addMoreRows() function is client side javascript function that add one row with input type=text.
and at the same time it increments the activeCategory value to activeCategory+1;
id of the input control txtBox1,for next time it would be txtBox2 ;

When serverside i used the following code
 string str = Request.Form["activeCategory"];
it returns only "0" which was previously set.

int totalCount=Convert.ToInt32(Request.Form["activeCategory"]);
int totalCount=Convert.ToInt32(activeCategory.Text);//since now it is aspx textbox control.

int i;
string newval=Request.Form["txtBox"+i];
//Unable to retrieve in previous scenario with html Control, since control is not transferred into for loop because of the value of activeCategory=0

Well I was able to figure out..
Solution- <asp:TextBox ID="activeCategory" runat="server"></asp:TextBox>

Client/Customer want the solution and we achieved it.Still I am thinking...

1>I don't want aspx server control that will create on the server side and expose its properties and methods.

2>When i use normal HTML control and by client side script increment it's values ,why I am not able to get current value(incremented value),rather than I am always getting 0 value.
On the other hand for dynamic created textbox using javascript,I am getting value e.g.Request.Form["txtBox"+i] has value

e.g <Design time html Control>
  <form id="form1" runat="server">
      <input type="text" id="txtBox1" />
    <input type="text" id="txtBox2" />
    <input type="text" id="txtBox3" />
    <input type="text" id="txtBox4" />
   We do not get the value of txtBox1,2,3,4 using
either Request.Form["txtBox1"] or
string newval=Request.Form["txtBox"+i]; //where i=1,2,3;

<html Control-Using Client Side>
But when we create dynamic input using javascript on the client side I am getting the value
Request.Form["txtBox1"] or
string newval=Request.Form["txtBox"+i]; //where i=1,2,3;

3>Please do correct me if i think "normal HTML control is light weight than HTML Server Control/Web Server(aspx) Control"

Cheers :)