XPages and Dojo Radio Buttons - button

I using some Dojo radio buttons in an XPages application and would like to display the label, not the selected value, when the XPage is in read mode. Is this possible? Here is an example of my code:
<xe:djRadioButton id="C1B1_R1" groupName="FKRadio1" value="#{document1.C1B1_RValue}">
<xe:this.label><![CDATA[#{javascript:sessionScope.get("C1B1_R1")}]]></xe:this.label>
<xe:this.selectedValue><![CDATA[#{javascript:sessionScope.get("SV_C1B1_R1")}]]>
</xe:this.selectedValue>
<xe:this.rendered><![CDATA[#{javascript:var r3 = sessionScope.get("C1B1TextVisibility");
#If(currentDocument.isEditable(),#If(r3 != null && r3[0]!=0,true,false),
#Trim(#GetField("C1B1_RValue")) == sessionScope.get("SV_C1B1_R1"), true, false)}]]>
</xe:this.rendered>
</xe:djRadioButton>
In edit mode, the labels are displayed. However in read mode, the value of the field is displayed rather than the corresponding label for the field value. In this case, the values are all numeric while the labels are text.

Tony,
Three things that you should try, these are written in order you should try:
1) I think it is rendering as just plain text when in read mode, so it just shows the values. Try setting the "Show disabled control for read only" and see if it renders it as something other than plain text.
2) Change the code to be the same for read or edit mode, in other words make it like edit mode. Then use the styleClass to use jQuery or CSS to restrict editing.
3) Use a hidden input/display:none to load the field on the page, then set the label to a field that is shown

You can hidde the djRadioButton in read mode, and show a xp:text with the label instead.
Or, maybe with the property "Show disabled control for read-only" (in general properties of the Dojo Radio Button)

Related

How to display ipywidgets.Dropdown without a value selected

No question anymore. The problem is older ipywidgets version behaviour that looks to be fixed in version 7.
The ipywidgets.Dropdown on its own picks up the first value out of the options list.I would like to display the widget without a value selected.The first value in the list is a pointless default that still needs to be reflected down the workflow path. I read a discussion where a developer went as far as adding empty string item into the list. That fixes the dropdown look (to some extent though as the placeholder attribute is still ignored) but adds a silly selectable empty item to the dropdown list. Adding dummy "None" item to the list is not much better solution.Setting value to None results in the "Invalid selection" exception.I do not understand why the ipywidgets.Dropdown does not follow approach of the simpler widgets where empty value is allowed and placeholder text is dispalyed to prompt the user to select something.Is there a way to make the widget selection not required? Some attribute setting I am not aware of? If that is impossible then what is the simplest possible workaround?
You can just set the dropdown value to None:
import ipywidgets as widgets
d = widgets.Dropdown(options=['hello', 'world'], value=None)
d
in 'ipywidgets' version 7.2.1 you will need to disable user changes to be able to display the widget by setting it to False like this:
d = widgets.Dropdown(options=['hello', 'world'], value=None, disabled=False)

How can I change the background colour of a specific range of text within a text field? What type of text field can I use within my Web App?

I have a c#.net web app which has multiple asp:textbox fields. I want to be able to change the background colour or text colour of the text within this boxes but only a specific range so for example the first 200 characters are to be red, the remaining characters should be green.
I am aware you can't control the content of a asp:textbox field but I am using ASPNetSpell to perform inline spell checking on all boxes and this renders the field as a asp:textbox.
Does anyone have any idea how I can achieve this functionality: ability to format partial content within a field and apply a spell checker? I am open to any suggestions.
Any and all help greatly appreciated.
Laura
It looks like the ASPNetSpell textbox is rendered as a div so you should be able to format the text using jQuery. Here is a way you can do this:
$(document).ready(function () {
$("#aspnetspellbutton").bind("click", function(eventData) {
var textfrominputelement = $("#yourinputelementid").text().substr(0, 200);
textfrominputelement.fontcolor("Red");
});
});
Basically, your binding the aspnetspellbutton click event to the jQuery function and then assigning the first 200 characters of text from the aspnetspell textbox and then changing the color of that text to Red.
This is a terse example. Depending on your requirements it could be a little more complicated. Script Junkie is a great resource for jQuery if your new to it.
You need something like a RichTextBox control. Check this out as well, those could be your solution. Good luck!

ASP.NET hidden field vs. invisible textbox

what are benefits of using a hidden field in ASP.NET when we can use another invisible element such as label or text box?
The hidden field generate <input type="hidden" /> element on the page, which cannot be seen but the client can get the element, set the data and pass to the server:
document.getElementById('<%= SomeHiddenField.ClientID %>').value = "data_pass_to_server";
after postback you can get the value:
var clientData = SomeHiddenField.Value; // "data_pass_to_server"
If you're using invisible textbox (<asp:TextBox Visible="False" />), there's no element generated in the html file.
Either way works, for text box, don't use .visible="false"
use
yourTextBox.Style.Add("display", "none")
or
yourTextBox.Style.Add("visibility", "hidden")
A hidden field renders as input type="hidden" in the resulting HTML. Being an input the value in the input is submitted to the server on postback while this is not the case with a label. Depending on whether or not you want that value submitted to the server you should use input or label. If you don't want the value to be submitted then label is the right solution and hidden field is wrong.
I am not sure what you mean by invisible textbox but if you are trying to make it invisible via CSS keep in mind that the input type has semantic meaning to search engines, bots, etc. Also at some point your HTML might be served without CSS or with different CSS and the text box will become visible to the user. Otherwise there are no differences between hidden field and invisible text box as both of them render inputs.
Practically you can achieve the same thing with any of them, but since you want a "hidden field", semantically speaking the hidden field in ASP.NET is your best bet for readability reasons.

What is the easiest way to disable a form but keep it readable?

I have my form fields in a Panel which, if a read-only version is required, I set Enabled = False on the Panel. This was quick and dirty and the results are mostly dirty, mostly in IE. Can't scroll through large ListBoxes. Multi-line TextBoxes only show the first few lines. There's some funky styling to disabled Labels.
Do you have any ideas as to how to disable an entire form, letting the user read the data, visually indicating that it is disabled (gray input or text in place of input), but to the server keep the control disabled so it's not loading any data that could be manipulated by enabling fields by nefarious means.
(Also, I'm hoping I don't have to add a label corresponding to each data field.)
You could remove all the buttons and use jQuery to change the background color on all inputs. This would be a quick and easy solution.
$(':input').addClass('disabled');
You can have your fields assigned the readonly attribute, ie:
<input type="text" name=myText value="Enter Your Name" readonly>
This can easily be done with js but is more robust if done right in html.
You could also disable or even remove the submit button.
I would use the ASP web controls. The TextBox for the input type="text".
All web controls have the enabled property
<asp:TextBox id="txtSomething" runat="server" />
You can now enable/disable all controls from code like you do today (for the panel). But you have to do it for every one (I don´t know how many you have).
txtSomething.Enabled = False
You can also do this with JavaScript.
Loop all elements in the form, and disable/enable them.
function DisableEnableForm(myForm,setDisable){
elems = myForm.elements;
for(i=0;i<elems.length;i++){
elems[i].disabled = setDisable;
}
}
You can trigger this JavaScript function from ASP like this:
Button1.Attributes.Add("onclick", "javascript:DisableEnableForm(´form1´,true)");

Textfield value empty when I fill it with javascript

I am using modalpopup to enter some value in a textfield. After the value is selected in the modalpopup view, the modalpopup is closed and the value takes the appropriate value. Even if the value is displayed in the textfield, the textfield1.text returns an empty string. When I see the source code (html), I see that even the textfield isn't displaying anything; it hasn't really had this value input, because the appropriate html input field hasn't got a value yet.
This is the code I use to fill this textfield:
function CloseRequestModal(s)
{
document.getElementById('<%=txtRequest.ClientID%>').value = s;
var mpu = $find('<%=ModalPopupExtender3.ClientID%>');
mpu.hide();
}
Please help.
I would need to see source HTML cause it looks like you have template language mixed into your javascript but perhaps instead of "textfield1.text" you use "textfield1.value"?
Additionally, you would need to view "generated" source (with a browser plugin) or inspect the node with web inspector on safari/chrome or firebug on firefox in order to see the change that you made with javascript.
i fixed this problem in an alternate way.
even if the value is there (in the textfield), none of the events is fired, to let know the browser / compilator that the value really exists.
so i decided, despite editing the value of the textfield, i store this value in the session too. in this case, the value is displayed for user needed in the interface, and on the other hand i use the value that i stored in the session.

Resources