Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 16th, 2007, 09: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
  #2 (permalink)  
Old February 16th, 2007, 09: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
  #3 (permalink)  
Old February 16th, 2007, 09: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

  #4 (permalink)  
Old February 16th, 2007, 10: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


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 02: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





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