Click here to Skip to main content
15,888,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I took a aspx page but i want to use the controls of html not asp that means i used input type text field and with that field i want to put value of a variable with vale ex:-
HTML
<input type="hidden" name= "T1" value="abc"/>

in above code with value i don't want to fix the text here i want to assign the value by a variable . Please give the appropriate solution for it.
Posted
Updated 1-Feb-12 18:57pm
v2

VariableName is define in code code behind
C#
<input type="hidden" name= "T1" value="<%=VariableName%>"/>
 
Share this answer
 
v3
Comments
Anuja Pawar Indore 2-Feb-12 1:50am    
Added pre tag
Use Javascript to assign values to html controles

Use any one of the below.

C#
 getElementById("element_id");
getElementByName("element_name");



For your sample code, you can assign value like this
document.getelementbyname('T1')="def";


Thanks

SP
 
Share this answer
 
v2
Comments
Rajesh Anuhya 2-Feb-12 1:08am    
Missing Code tag added
--RA
Sridhar Patnayak 2-Feb-12 1:09am    
Sorry, Thanks Rajesh
Include "id" to your input tags and and runat="server" for you to access the
controls and assign a value
C#
<input id="T1" type="hidden" name= "T1" value=""  runat="server" />



C# Code behind
C#
var data = "sample"

this.T1.value= data;
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 2-Feb-12 1:51am    
Added pre tag
HTML
<input type="hidden" name="T1" value="<%= YourFunction() %>" />


where yourFunction() is a function in your code behind that returns a string
 
Share this answer
 
XML
If not registered, click
<% if (upLevelBrowser) {%>
<a href="javascript:ShowRegisterDlg">here</a>
<% } else {%>
<asp:linkbutton runat="server" text="here" onclick="ShowRegisterDlg" />
<% } %>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900