2013年9月11日星期三

@ ViewBag brought the value into a string format

how
 This post last edited by the wozaiztam on 2013-09-12 10:18:00
I now have a @ ViewBag.User.Birthday is datetime format , you need to get in front of their respective year, month , day, think of it first into a string format , as follows:

  
 <script type="text/javascript">
  var a = @ViewBag.User.Birthday.ToString();
  //....
 </script>



But the error:
SyntaxError:
missing; before statement
var a = 1905/2/5 0:00:00;





------ Solution ------------------------------------ --------
var a = "@ViewBag.User.Birthday.ToString();"

------ Solution -------------------------- ------------------
assume the background setting
ViewBag.Message=null;

Front judgment

<input class="text" id="Tel" value="@(ViewBag.Message == null ? "为空时显示值" : ViewBag.Message)"/>

------ Solution ------------------------------------- -------
<input type="text" id="Tel" value="@(ViewBag.User.Tel??"为空时的值")"/>

------ For reference only ------------------------- --------------
wood anybody here ?
------ For reference only -------------------------------------- -
var a = "@ViewBag.User.Birthday.ToString()";


enclose a little more


------ For reference only ---------------------------------------
Why do not you turn a good background , directly to the front desk it ?
------ For reference only -------------------------------------- -
just turn the code is being written back , huh, huh , thank you ah
------ For reference only --------------------- ------------------
embarrassed , ask

  <input class="text" id="Tel" value="@ViewBag.User.Tel"/>


@ ViewBag.User.Tel judge me how it is not empty ?

没有评论:

发表评论