Click here to Skip to main content
15,891,851 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have this code of next button but i face an error...
'HiddenField' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'HiddenField' could be found (are you missing a using directive or an assembly reference?)

CAn anyone help me to solve this problem?

What I have tried:

protected void Button2_Click(object sender, EventArgs e) { int count = 0; if (HiddenField1.Text.Trim()!= null) count = Convert.ToInt32(HiddenField1.Text) + 1; i++; if (count < ds.Tables[0].Rows.Count - 1) { TextBox1.Text = ds.Tables[0].Rows[count]["Question"].ToString(); Label2.Text = ds.Tables[0].Rows[count]["Choice1"].ToString(); Label3.Text = ds.Tables[0].Rows[count]["Choice2"].ToString(); Label4.Text = ds.Tables[0].Rows[count]["Choice3"].ToString(); Label5.Text = ds.Tables[0].Rows[count]["Choice4"].ToString(); Label6.Text = ds.Tables[0].Rows[count]["Choice5"].ToString(); HiddenField1.Text = count.ToString(); } else { Response.Write("You have reached the end of records in this category!!"); }}
Posted
Updated 27-Aug-17 23:47pm
Comments
Thomas Nielsen - getCore 28-Aug-17 3:03am    
Much depends on your html in this case. what type is that HiddenField1? do include your html snip at least with the hidden field, it could be input type hidden or server side control?? Basically it's telling you that you're access an property by name on the dom object which it doesn't have.
Member 13361792 28-Aug-17 5:38am    
This code display only first two record after second record next button is not working. Can u help me plz...
Member 13361792 28-Aug-17 5:44am    
This code only display the first two records, it's not displaying record after second record. Can you help me to solve this problem?

Thanks in advance
Thomas Nielsen - getCore 30-Aug-17 3:58am    
I hope i might be of assitance, but without the actual html and code behind it's difficult to see where your bug is. First off Kerthik is right, there is no property called Text in the asp.net hiddenfield control so it could be something simple like that though: http://www.c-sharpcorner.com/article/hidden-field-in-asp-net/

1 solution

HiddenField doesnt have Text Property, use HiddenField.Value Property [^]
 
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