Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 18, 2010 08:37 AM by andrewjboyd
Member
442 Points
405 Posts
Aug 16, 2010 07:10 AM|LINK
Hi,
I got in the controller action:
var reports = new List<Report>();
reports.Add(new Report {Title = "Inventory (monthly)"});
reports.Add.......
However, the words are truncated when passed to the view.
The words after the space is truncated, any idea?
ie. it just passed the word "Inventory".
Contributor
4426 Points
864 Posts
Aug 16, 2010 08:07 AM|LINK
If you put a break point in your controller, does the variable contain "Inventory (monthly)"? It's sounding more like an instantiation issue
Aug 16, 2010 11:05 AM|LINK
It looks like the space caused the problem, I tried shorter string eg. alan (123)
and display the Title on .aspx's button value it only shows alan
All-Star
134491 Points
21566 Posts
Moderator
MVP
Aug 16, 2010 11:17 AM|LINK
AlanT display the Title on .aspx's button value it only shows alan
If you display into html, how's the source ? I think that maybe has an invalid char ( line newline ?)
Aug 16, 2010 10:41 PM|LINK
Can you drop in here the source you're using to display Report.Title?
Aug 16, 2010 11:19 PM|LINK
I use this:
<input type="submit" name="testReportTitle" value= <%: Model.Report.Title %> />
Did I miss something?
Thanks
Aug 16, 2010 11:35 PM|LINK
You are encoding the text, change
to
<input type="submit" name="testReportTitle" value= <%= Model.Report.Title %> />
Notice I'm using "=" instead of ":"
Aug 16, 2010 11:50 PM|LINK
Think about it a bit more, maybe change it to
<input type="submit" name="testReportTitle" value= <%= Html.Encode(Model.Report.Title).Replace(" ", " ") %> />
Aug 16, 2010 11:55 PM|LINK
What does List<Report> have to do with Model.Report.Title?
Aug 17, 2010 03:43 AM|LINK
I do a
<ul>
<% foreach (var repor in Model.Reports)
{ %>
<li> .......</li>
<% } %>
</ul>
I guess I will pick up the last report in the list.
AlanT
Member
442 Points
405 Posts
Pass model to view - List<...> truncated after space
Aug 16, 2010 07:10 AM|LINK
Hi,
I got in the controller action:
var reports = new List<Report>();
reports.Add(new Report {Title = "Inventory (monthly)"});
reports.Add.......
However, the words are truncated when passed to the view.
The words after the space is truncated, any idea?
ie. it just passed the word "Inventory".
andrewjboyd
Contributor
4426 Points
864 Posts
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 08:07 AM|LINK
If you put a break point in your controller, does the variable contain "Inventory (monthly)"? It's sounding more like an instantiation issue
================================================
Why catch a fish to feed someone, when you can teach them to fish and they can feed themselves
AlanT
Member
442 Points
405 Posts
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 11:05 AM|LINK
Hi,
It looks like the space caused the problem, I tried shorter string eg. alan (123)
and display the Title on .aspx's button value it only shows alan
ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 11:17 AM|LINK
If you display into html, how's the source ? I think that maybe has an invalid char ( line newline ?)
andrewjboyd
Contributor
4426 Points
864 Posts
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 10:41 PM|LINK
Can you drop in here the source you're using to display Report.Title?
================================================
Why catch a fish to feed someone, when you can teach them to fish and they can feed themselves
AlanT
Member
442 Points
405 Posts
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 11:19 PM|LINK
Hi,
I use this:
<input type="submit" name="testReportTitle" value= <%: Model.Report.Title %> />
Did I miss something?
Thanks
andrewjboyd
Contributor
4426 Points
864 Posts
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 11:35 PM|LINK
You are encoding the text, change
<input type="submit" name="testReportTitle" value= <%: Model.Report.Title %> />
to
<input type="submit" name="testReportTitle" value= <%= Model.Report.Title %> />
Notice I'm using "=" instead of ":"
================================================
Why catch a fish to feed someone, when you can teach them to fish and they can feed themselves
andrewjboyd
Contributor
4426 Points
864 Posts
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 11:50 PM|LINK
Think about it a bit more, maybe change it to
<input type="submit" name="testReportTitle" value= <%= Html.Encode(Model.Report.Title).Replace(" ", " ") %> />
================================================
Why catch a fish to feed someone, when you can teach them to fish and they can feed themselves
andrewjboyd
Contributor
4426 Points
864 Posts
Re: Pass model to view - List<...> truncated after space
Aug 16, 2010 11:55 PM|LINK
What does List<Report> have to do with Model.Report.Title?
================================================
Why catch a fish to feed someone, when you can teach them to fish and they can feed themselves
AlanT
Member
442 Points
405 Posts
Re: Pass model to view - List<...> truncated after space
Aug 17, 2010 03:43 AM|LINK
Hi,
I do a
<ul>
<% foreach (var repor in Model.Reports)
{ %>
<li> .......</li>
<% } %>
</ul>
I guess I will pick up the last report in the list.