how to add a conditional statement into .aspx page controlled by angular js - asp.net

working with asp page and I need to change "true-false" statement on table. But I couldn't figure out how to add "string" instead of boolen data on asp page. That's asp code block, which I need to change it.
<tr data-ng-repeat=" ticket in ticketList">
<td>{{ticket.UserId}}</td>
<td>{{ticket.State}}</td>
<td>
I tried to do that
<td>{{<%# ((bool)Eval("ticket.State") != false) ? "Tested" : "NotYet" %>}}</td>
but, It doesn't work. how can I put a conditional statement into that cod block. Thanks for any advice.

Since this is angluar JS app, you can not use <%# Eval .. %> thing here. You might have noticed that you are using loop with ticket in ticketList in data-ng-repeat.Point is you can not apply server side implementation for rendering there. You need to do in angularjs way. Following are some examples to do it.
If you have angularjs version >= 1.1.5, then following way would work.
<td>{{ticket.State === "false" ? "Tested" : "NotYet"}}</td>
For lower version, this will be helpful - inline conditionals in angular.js
Or there are other directives like ng-show, ng-hide, ng-switch, you can try those too!

Related

How do I solve my layouts being messed up due to fields_with_error in RoR app?

I'm using Fomantic(Semantic) UI in my Ruby on Rails, and I realize my forms get messed up when validations fail because of the fields_with_errors class that's automatically added. Is there a known fix for this?
Prior to submission, my form looks like this
After a failed submission, where nothing is entered in any of the field, it looks like this
In one of my projects I use the following code inside config/application.rb
config.action_view.field_error_proc = Proc.new do |html_tag, instance|
%Q(<div class="field error">#{html_tag}</div>).html_safe
end
This code uses semantic way of indication of fields in error state. You can further customise this setting to your needs, see rails docs for details.
Next important point is an extra check on your form tag to add semantic ui form error class, something like:
form_for(#model, html: {class: #model.errors.any? ? 'ui form error' : 'ui form'}) do |f|
This will show error messages if you use them.

Escape field inside Control loop

New to SilverStripe and trying to decypher how things work.
I have a field in a page which I used to store some HTML code. When you view their "Holder" page, it loops over each child page and displays them all. The problem I am running into is that when I output the value it's escaping it - so I need to be able to decode it.
<% control Children %>
<h2>$Title </h2>
$ExtraHtmlBody <!-- This is escaping when outputting -->
<% end_control %>
So I tried to add a function inside my Page_Controller, but it seems that I can not call Page_Controller methods from inside the Control loop. I tried moving the function into the Page class, but it doesn't seem to have any data for $this->ExtraHtmlBody. Maybe I'm doing something wrong.
You data might already be escaped in the database itself. did you check?
Like #munomono said, if you are storing html use HTMLText or HTMLVarchar.
You can also try to disable auto-escaping in your template with $ExtraHtmlBody.RAW (at your own risks).
some info here:
http://doc.silverstripe.org/framework/en/topics/data-types#casting-html-text
http://doc.silverstripe.org/framework/en/topics/security#what-if-i-can-t-trust-my-editors
http://doc.silverstripe.org/framework/en/reference/templates#formatting-and-casting
Your controller function problem is probably just a scope issue since <% loop %> changes the scope, $Up/$Top might help. But you probably don't need that function anyway.

setting Style property of a WebControl From Code Behind

recently I found in one of my older projects (asp.net 4.0)
that I've been using this code
to set display Style-property To none
DDL_ChosenEmpl.Attributes.Add("style", "display:none");
lately I was using
DDL_ChosenEmpl.Style.Add("display", "none");
i would like to know
in any case such as - property already exist whether it's with different value or not , will any of them should be avoided ?
what are the main differences between both methods ?
Both does the same functionality as you have done. The thing is, in "Attributes" collection, you have a control's other attributes like "click", "dblclick", etc. You can use either way. I believe Microsoft has given the later part for user's convinience to make coding easy.

weird Ajax ComboBox drop down list

I've got combobox inside some panel :
<ajaxToolkit:ComboBox
ID="YearList"
runat="server"
OnInit="YearList_Init1"
EnableTheming="false"
Width="45px"
ViewStateMode="Disabled" />
and it was OK before I updated project to .NET 4 , after updating project (And AJAX) to .net4 it's looking like really strange ... I can't explain it proper , I will show :
how can I fix it ? :) Full CSS / ASPX page here -> https://github.com/nCdy/Issues/tree/master/Ajax%20ComboBox (string # 287)
I had a similar issue and could resolve mine by removing the extender that I had added to the Panel containing the combobox. I had used a DropShadowExtender for the Panel, removing it caused the combobox to be displayed perfectly. Perhaps you can try that as well.
i am seeing a lot of texts like
Контрактный час
:
, every where in your form. So i need to know, are you using some sort of encoding , that is, is this placed by you or came unexpectedly. If you havent placed it, remove all unneccessary such lines and use plain text instead (if required). Then check the layout.
Also in your image, i can see , ur language is russian(if i am right :)). So try using your localized font that is direcly supported by aspx as we use english or better use resource file instead of the hardcoded text on the page. As per my view the language conversion is creating such issue.

jQuery syntax while using master Page

I am using master page where i need to move value of one listbox to the other with the help of jQuery I tried many ways but wasn't able to hit the nail.
The methods I tried are as follows:
$("[id$='ModuleMasterListBox option:[#selected]']").appendTo($("[id$='ModuleSelectListBox']"));
$("[id$='ModuleMasterListBox option:#selected]'").appendTo($("[id$='ModuleSelectListBox']"));
var module = $("[id$='ModuleMasterListBox']").val();
module.appendTo($("[id$='ModuleSelectListBox']"));
These are the methods I tried which failed - please help me out....
You should be able to do it like this:
$("[id$='ModuleMasterListBox'] :selected").appendTo("[id$='ModuleSelectListBox']");
From your markup and the # sign it looks like you're using an outdated version of jQuery, you may want to consider upgrading. In the above we're using the attribute-ends-with selector to get the <select> the using :selected to grab the selected <option> before moving it.
Keep in mind since it looks like you're using ASP.Net this will by default throw validation errors on the server-side, you'll have to disable page validation for it to allow items it didn't bind.

Resources