0

Is this right? I am trying to display value in input box dynamically?

can anyone advice me is this corect approach? but still I am getting here only + + in input box?

2
  • 62% isn't too bad - OP's unaccepted questions are all relatively recent. But point stands @kumar, please accept some of your other answers if possible. If you haven't got an acceptable answer try editing your question, this will bump it up the lists. Commented May 17, 2010 at 20:57
  • Hello David.. Thanks please check my previous post I am answering the question wchih the people helping me out.. lot..I am very thankfull to those guys who are helping me... check it out my post which I answered.. Commented May 17, 2010 at 21:06

2 Answers 2

4

Html.DisplayFor will render a label in this case. If you want to write in this way just use <%= Model.Date.ToString() %> for the value attribute of the input.

These HTML helpers will render the markup for you, don't try and use them as methods to return data. You can get the data by just using <%=Model.MyProperty%> as long as it is a strongy-typed view.

Try just using <%= Html.EditorFor(m => m.Date) %>

OR

<%= Html.TextBoxFor(m => m.Date) %> (the EditorFor will automatically render a textbox anyway)

OR

<%= Html.TextBox("Date", Model.Date) %> (this is not a strongly-typed helper, you're doing the data binding yourself with the second argument)

Sign up to request clarification or add additional context in comments.

1 Comment

In that case just use a Html.TextBox - if it's input then you won't be binding to any data. If it's editing then use Html.TextBoxFor or Html.TextBox("Date",Model.Date.ToString()).
1

Maybe do you want this?

<input 
  type="text" 
  id="Date-<%=Model.ID%>" 
  value= " <%= "+" + Model.Date.ToString() + "+" %>"  /> 

I don't know what Model is for you, but something like this might help you, if it is an object of a class that has some property Date.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.