15,904,828 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13098156 (Top 2 by date)
Member 13098156
17-Feb-20 4:17am
View
Can you make both examples please?
In the meanwhile I have made some experimentations and in javascript the following lines work properly and they assign the value to the HiddenField1 placed into the .aspx page:
var id= "1";
$("#HiddenField1").val(id); //HiddenField1 is now "1"...it works!
In my case the issues are (to be a bit more precise):
1) In the code behind
string test = form1.HiddenField1.value does not work (error: HtmlForm does not contains a definition for HiddenField1)
2) In the code behind
string test = HiddenField1.Value seems to be accepted (no error messages) but test is always an empty string, despite the fact that $("#HiddenField1").val(id) is working properly
So...in a nutshell:
1) How can I access from code behind to
string test = HiddenField1.Value
2) if I have a method like this in the code behind
public string getState (string id)
{
string tempvalue = "";
if (state == "1"){tempvalue = "image1.png"}
if (state == "2"){tempvalue = "image2.png"}
return tempvalue;
}
how can I pass the value id to the method from the .aspx page?
In the .aspx page the statement
var id = 1;
var icon = "<%getState (id)%>";
gives the error "The name 'id' does not exist in the current context".
Hoping I have been clear, thanks in advance for your support.
Member 13098156
14-Feb-20 11:22am
View
Dear Karthik,
I have the same problem: could you please make an example about your answer?
what do you mean for "u will using form object to read the client controls value."
I have:
form id="form1" runat="server"
and
<asp:hiddenfield id="HiddenField1" runat="server" clientidmode="Static" validaterequestmode="Enabled" viewstatemode="Enabled">
How can i access it from code behind?
string test = form1.HiddenField1.value; does not work at all!
Regards