Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 13th, 2008, 02:13 AM
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
Default Access input controls generated by Client Script

 how to access input controls in "asp net" 2.0 generated by client side scripts

e.g onclick of the button will automatically add some textboxes (from client side) ,so that user can enter multiple entries,now I want to access those textboxes values .

i tried something in Code behind file
string newval=Request.Form["txtBox"+i];
where i is any number.
Any input or pointer would be highly appreciated!!







Cheers :)

vinod
__________________
Cheers :)

vinod
  #2 (permalink)  
Old April 13th, 2008, 11:52 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What happened when you tried that? Presumably it didn't work, otherwise you wouldn't be posting here. So how did it not work?

-Peter
peterlanoie.blog
  #3 (permalink)  
Old April 14th, 2008, 05:11 AM
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
Default

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"]);
or
int totalCount=Convert.ToInt32(activeCategory.Text);//since now it is aspx textbox control.

int i;
for(i=1;i<=totalCount;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" />
      </form>
   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 :)

vinod
  #4 (permalink)  
Old April 14th, 2008, 08:33 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can you post the client side code you are using to add the control and update the text box value?

3> Any HTML in your ASPX markup that is not a server control will be seen as just literal text. If you looked at the page's control tree, you would see a Literal class control in the sequence of controls between your server controls. So, yes, to a certain extent plain HTML may be lighter, but in the grand scheme of things, it probably doesn't make much of a different. In the end you still have some control, whether it's a server-textbox or just literal text.

-Peter
peterlanoie.blog
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access controls, vba and arabic script tunsted Access VBA 0 January 17th, 2008 01:22 PM
How to store the dynamically generated controls ? ramesh1520 ASP.NET 2.0 Basics 0 January 2nd, 2008 10:30 PM
Read input from Dynamically Controls sois C# 3 August 20th, 2007 06:56 PM
input validation at client end guru_gautam ASP.NET 1.0 and 1.1 Professional 0 February 9th, 2007 06:03 AM
Postback from client script gp_mk HTML Code Clinic 2 April 14th, 2004 02:48 AM



All times are GMT -4. The time now is 03:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.