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 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking 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 Basics 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 16th, 2007, 08:11 AM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Kolkata, West Bengal, India.
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML tag from C# or ASP.NET tag from javascript

Hello,
I have a problem.
I want to access HTML tag from C# code(hidden field).
or
I want to access ASP.NET tag from javascript.
Which one is possible and how?

Angshujit

__________________
Angshujit
Reply With Quote
  #2 (permalink)  
Old February 16th, 2007, 08:39 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

To access the hidden field in code, add a runat=server attribute to the tag so: <input type=hidden name="hiddenfield" runat=server />

If you just want to get the value and don't want to manipulate the box in code you can do Request.Form("hiddenfield")

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
Reply With Quote
  #3 (permalink)  
Old February 16th, 2007, 08:58 AM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Kolkata, West Bengal, India.
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
Thank you for your reply.
I have created a hidden field...

      <input type="hidden" id="action" runat="server" />

Then I have changed the value of the field from javascript(According to my choice). Then I have tried to access the value of the field from C# (on a button click event) ...

      string actn = Request.Form("action").Value;

But it is showing a error...
'System.Web.HttpRequest.Form' is a 'property' but is used like a 'method'

What to do?
Angshujit

Reply With Quote
  #4 (permalink)  
Old February 16th, 2007, 09:07 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This should work:

string actn = Convert.ToString(Request.Form.Get("action"));

Also, if you are using the above method, you do not need the runat=server attribute in the hidden field. The runat attribute is used to manipulate an HTML control in code, you are simply trying to get its value.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
Reply With Quote
Reply


Thread Tools
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
HTML tag problem Aker C# 7 April 22nd, 2008 11:04 AM
Trying to pull data between two different HTML tag boniggy Visual Basic 2005 Basics 0 February 6th, 2008 01:36 AM
TEXTAREA tag in html sapphire87 PHP How-To 0 July 26th, 2006 02:25 PM
HTML tag vs Body Tag CFGerry BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 October 7th, 2005 07:13 AM
Using HTML Tag on Netscape Composer futurika HTML Code Clinic 1 October 24th, 2003 11:45 PM



All times are GMT -4. The time now is 02:26 AM.


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