I have a button in aspx page, I want to set its Enabled property using code behind variable.
I did it like this:
'>
It gives me error message: Cannot create an object of type 'System.Boolean' from its string representation '<%=this.AllowDelete %>' for the 'Enabled' property.
I changed it to Enabled = <%=this.AllowDelete %>,
It gives me error message: Server tags cannot contain <% ... %> constructs.
I tested <%=this.AllowDelete %> in other place of page, it shows 'false' correctly.
How to set it for enabled property correctly?
It's such a simple question but stuck me for a while. Any help is appreciated. Thanks you!
I know this doesn't exactly answer your question, but are you able to set the button's enabled property in Page_Load function in your code-behind?
Page_Load(...)
{
if(this.AllowDelete)
btn.Enabled = true;
...
Related
I've got a search form that returns our products. However, if a user inputs a string that contains certain words (in this instance, 'color'), it returns far too many products. I'm trying to remove the string 'color' from the query that is searched on the backend, but maintain the original query's string as #unfiltered_query so I can reference the #unfiltered_query on the front-end template.
if query.include? "color"
#unfiltered_query = query
end
query.slice! "color"
values = query.split
binding.pry
It was not working, so I ran pry to see what was going on. In the form, I searched "Red paint color". When I call #unfiltered_query in pry, it outputs "Red paint", even though I create the method before .slice! is called?!
What am I missing?
Thank you!
p.s. the HTML template that I'm using to reference the instance is:
<div class="search-input"><h2>
<% if #unfiltered_query.present? %>
<%= #unfiltered_query.titleize %>
<% else %>
<%= query.titlelize %>
<% end %>
</h2></div>
Can you try like this :
if query.include? "color"
#unfiltered_query = query.dup
end
query.slice! "color"
values = query.split
binding.pry
This could be due to passing by reference.
I'm trying to make some code on VB.net that opens a website and logs in, and after that runs a report. Everything has been working fine when I try to get any of the from the website, but the ones that have this instruction within the OnClick property = "return oamSubmitForm('inputParamView:paramForm','inputParamView:paramForm:_idJsp106');"
Basically, if you see the following code, you see that I click on some of the CheckBoxes and it works just fine, but when I retrieve the button, it doesn't type an input, it actually has the link of the website when I use a whatc while debugging.
This is my code (I skipped the login section):
Private Sub open Page()
ieb = New SHDocVw.InternetExplorerMedium()
ieb.Navigate("http://example.example/qptheme2/pages/index.faces")
ieb.visible = True
ieb.Silent = True
While Not (ieb.ReadyState = WebBrowserReadyState.Complete)
Application.DoEvents()
End While
If v.checked = False Then
v.Click()
End If
v = ie.Document.GetElementById("inputParamView:paramForm:inputParametertuesday")
If v.checked = False Then
v.Click()
End If
v = ie.Document.GetElementById("inputParamView:paramForm:_idJsp106")
v.Click() '<-- IT FAILS HERE Exception HRESULT: 0x800A01B6
If I check the watch it shows mshtml.HTMLAnchorElementClass {http://example.example/qpreport/savedpages/savedReports.faces#}
if I check the source code from the page, this is the element that I'm trying to get:
<a id="inputParamView:paramForm:_idJsp106" onclick="return
oamSubmitForm('inputParamView:paramForm','inputParamView:paramForm:_idJsp106');" href="#"
I don't know if it has anything to do with the property OnClick.
I will appreciate any of your help trying to solve this issue.
I found the solution by myself. I just had to instance the element I was retrieving as mshtml.HTMLAnchorElementClass
after that, I was able to click on it.
Dim l As mshtml.HTMLAnchorElementClass = ieb.Document.GetElementById("inputParamView:paramForm:_idJsp106")
l.click()
I am trying to implement multiple submit buttons in a Struts jsp. To do so, I am passing the value of the submit button to the ActionForm and reading that value. My setup is like this:
JSP
...snip...
<form name = "formName" action = "action.do" onSubmit = "return myFunc()" method = "POST">
<input type = "text" name = "myValue" />
<input type = "submit" name = "myButton" value = "Submit" />
</form>
...snip...
MyForm
...snip...
String myButton;
String myValue;
[Generated getters and setters]
...snip...
As far as I can tell, the submit button from the jsp should submit a value of 'Submit' to the myButton variable in MyForm, but when I try to access it in the Action Class I always get a value of null.
I know that my struts-config.xml file is configured properly because the text input in the jsp successfully populates the 'myValue' variable in MyForm, which can be read by my Action Class.
Is there something special about submit buttons in Struts that I am missing? It seems everything should work...
Any help would be appreciated.
You need to use a input type hidden for that, value property of submit buttons is only used for text on the button not for sending that value with the rest of the form data.
It is possible by using Struts JSP tags to define the form and the submit button. Why dont you use Struts JSP tags?
<html:form action="action.do">
<html:submit property="myButton" value="Submit"/>
Hope it helps
I want to show a popup dialog containing a dijit.ComboBox with data populated using ajax request or data store.
The problem I am facing is that the combobox is always disabled.
My selected code is:
<div dojoType="dojo.data.ItemFileReadStore" id="osTypeStore" data-dojo-id="osTypeStore" url="/AjaxPopulateOS.json">
</div>
<select id="osType" data-dojo-type="dijit.form.ComboBox"
data-dojo-props="
id:'osType',
store: osTypeStore,
placeHolder: 'Select a schdule type'" >
</select>
Any ideas
I believe it is because there are no items in it? Is it grayed out totally - and have the Disabled class parameter set?
Check that dijit.byId('osTypeStore') returns a store and that it has items in it.
If this is the case, change your code to
store: 'osTypeStore'
Note the quotes. This forces parser to evaluate the string into a dijit - and the store might not have been initialized correctly as a true variable at the point it is read. In other words, in combobox constructor - the javascript variable is undefined.
If this does not help, try forcing to set store after onShow has run for your dialog.
dialog.onShow = function() {
dijit.byId('osType').set('store', dijit.byId('osTypeStore'));
}
Try forcing it to enabled using the property of the combo
enabled: true,
Other than that, check it using Firebug or debug bar or something similar :)
If i have the following javascript code
var myVar = 0;
function setNewValforVar(newValue){
myVar = newValue;
}
and i'm calling setNewValforVar function n times
so when I click on a link it'd send myVar value to the controller action in a remote link like
<%=link_to "My Link",{:action=>"myAction"},:data=>''sval='+myVar',:remote=>true%>
I Rails 2.3.x I'd do this with
<%=link_to_remote "My Link",:url=>{:action=>"myAction"},:with=>"'sval='+myVar"%>
and i was getting this on the controller's action with
params["myVar"]
how do I do this on Rails 3 with the link_to helper?
Rails 3 no longer supports this behavior. You will have to either create a form to submit the value, or modify the href of the link to include the value in the query string.
I found some solution that use callbacks. Link must be marked in some way, for example by adding the id:
<%=link_to "My Link", {:action=>"myAction"}, :remote=>true, :id => "mylink" %>
There is an example for prototype_ujs: the parameter is simply appended to the request's URL (the code is a bit simplified I assume that some parameters already exist).
<%= javascript_tag("document.on('ajax:create', 'a#mylink',
function(event) { event.memo.request.url += '&sval=' + myVar; })") %>
Some advantage of this (ugly a bit) solution is the possibility of using one function for a particular class of links instead of the indicated id.