syntax error for ASP.NET onclick - asp.net

I am modifying an asp.net page which has the following code:
<input type="button" id="room22SendEmail" name="room22SendEmail" value="Send" onclick="SendEmail('<%=mainValue%>');"/>
but there is an error after "SendMail('<%.." unterminated string constant. If I remove the single quotes I get a syntax error.
Whether it is
onclick="SendEmail(<%=#mainValue%>");'>
or
onclick="SendEmail(<%=mainValue%>");'>
I get the syntax error in the same places, marking the ( and )

Related

RCurl postForm issues with fieldnames with special characters

How do I enclose a field name to postForm with RCurl when the form has fields like those below?
<input id="form:checkEstrato" type="checkbox" name="form:checkEstrato" checked="checked" />
<input id="form:checkArea" type="checkbox" name="form:checkArea" checked="checked" />
if I try something like
if(url.exists(url))
results <- postForm(url,
form:evento="35",
form:area = "10")
I get
> if(url.exists(url))
+ results <- postForm(url,
+ form:evento="35",
Error: unexpected '=' in:
" results <- postForm(url,
form:evento="
> form:area = "10")
Error: unexpected ')' in " form:area = "10")"
in fact it was simple, although now I have to work it out why Rcurl doesn't get what I want.
At least to avoid de above error it as just a matter of enclosing the parameter name with quotes
if(url.exists(url))
results <- postForm(url,
'form:evento'="35",
'form:area' = "10")
Now lets move ahead trying to understanding what is being sent to server and why its not working the way I expected.

How to determine css's class with if statement

<div class="<%#((int)Eval("Cevaplanma_Sayisi")>0) ? "divcevaplanmasayisiozel" : "divcevaplanmasayisinormal" %>">
my code is above.the code runs when I use access database but it doesnt run with sqlserver2008 where is the error.it says when I runs the code invalid exception handled
Try this:
<div class='<%#(((int)Eval("Cevaplanma_Sayisi"))>0) ? "divcevaplanmasayisiozel" : "divcevaplanmasayisinormal" %>'>
The first problem is that you need to convert the object value of "Cevaplanma_Sayisi" into int.
The second problem is that you must wrap the Eval statement within ' and ', otherwise you get malformed html.

Custom error in validation is not show in h:message

I want to show a custom message when user insert a wrong input for a Double value but when i test my application i always see the default error message.
That's my custom messages.properties:
`javax.faces.convert.DoubleConverter.CONVERSION=My Conversion Error(Double)
javax.faces.convert.DoubleConverter.CONVERSION_detail=My Conversion Error(Double)
javax.faces.component.UIInput.CONVERSION=My Conversion Error
javax.faces.component.UIInput.CONVERSION_detail=My Conversion Error(Double)
javax.faces.validator.NOT_IN_RANGE=My Validation Error
javax.faces.validator.NOT_IN_RANGE_detail=My Validation Error
javax.faces.validator.DoubleRangeValidator.LIMIT=Validation Limit Double
javax.faces.validator.DoubleRangeValidator.LIMIT_detail=Validation Limit Double
javax.faces.validator.DoubleRangeValidator.TYPE=Error Type Double
javax.faces.validator.DoubleRangeValidator.TYPE_detail = Error Type Double
javax.faces.component.UIInput.REQUIRED=Requested!!
`
And here my faces.config
`<application>
<message-bundle>it.exaple.messages.MyMsg</message-bundle>
</application>`
And here my page:
`<td>
<h:inputText id="Value" value="#{user.value}" required="true">
<f:validateDoubleRange minimum="0.0" maximum="200.0"/></h:inputText>
<h:message for="username" showDetail="true" showSummary="true" style="color:red"/>
</td>`
It's really strange because when i test my application with an empty value i can read my customized message, but when i try to insert a string i see the default error message!! Same thing happen when i put a to high or too low value!
Anyone can help me? Thanks!
I hope you must override these default message to validate range of double. And I hope you have defined user.value as double in your managed bean.
javax.faces.validator.DoubleRangeValidator.MAXIMUM
javax.faces.validator.DoubleRangeValidator.MINIMUM
javax.faces.validator.DoubleRangeValidator.NOT_IN_RANGE

Error in ValidationExpression when using in XSLT

My XSLT shows that there is error in the below line, but i could not figure it out
<asp:RegularExpressionValidator ID="validatorEmail{#id}" runat="server" Display="Dynamic" ControlToValidate="{#id}" ErrorMessage="username#domain.com"
ValidationExpression="^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))#((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$" />
Error Message:
Expected token '}', found ','. ...+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2 -->,<-- }))#((([0-1]?[0-9]{1,2}|25[0-5]|... Forms.xslt
What is wrong with this?
In XSLT { and } are used to inject dynamic values in attribute value templates. You need to double them to escape them in your regular expression:
ValidationExpression="^(([\w-]+\.)+[\w-]+|([a-zA-Z]{{1}}|[\w-]{{2,}}))..."

Spring usage of typeMismatch messages

I have done some searches on the web and in stackoverflow to see how to handle the following message that I get on one of my screens:
Failed to convert property value of
type [java.lang.String] to required
type [java.lang.Long] for property
'qtyToShip'; nested exception is
java.lang.IllegalArgumentException:
Could not parse number: Unparseable
number: "a"
From research and from looking at the web I assumed that adding the following to my errors.properties file would produce the desired results:
typeMismatch.shippingCommand.qtyToShip=1. Invalid value for Qty To Ship, accepts only numbers.
typeMismatch.qtyToShip=2. Invalid value for Qty To Ship, accepts only numbers.
shippingCommand.qtyToShip=3. Invalid value for Qty To Ship, accepts only numbers.
qtyToShip=4. Invalid value for Qty To Ship, accepts only numbers.
typeMismatch.java.lang.NumberFormatException=5. Invalid value for {0}, accepts only numbers.
typeMismatch.java.lang.Integer=Must specify an integer value.
typeMismatch.java.lang.Long=Must specify an integer value.
typeMismatch.java.lang.Float=Must specify a decimal value.
typeMismatch.java.lang.Double=Must specify a decimal value.
typeMismatch.int=Invalid number entered
typeMismatch=Invalid type entered
I add integer values to the message to determine which one would show up.
Now at the top of my JSP I have the following:
<center>
<spring:hasBindErrors name="shippingCommand">
<c:if test="${errors.errorCount > 0 }">
<h4>Following errors need to be corrected:</h4>
<font color="red">
<c:forEach items="${errors.allErrors}" var="error">
<spring:message code="${error.code}" arguments="${err.arguments}" text="${error.defaultMessage}"/><br />
</c:forEach>
</font>
</c:if>
</spring:hasBindErrors>
</center>
The above is outside my Form, inside my Form I have the following (testing out ideals)
So the results is that when I run my code to trigger the error, I see that inside my form I get the following message:
1. Invalid value for Qty To Ship, accepts only numbers.
Which comes from this: typeMismatch.shippingCommand.qtyToShip
The outside of the form displayes:
Invalid type entered
What I do not understand is why am I able to display the correct message inside my form but not outside?
In the controller I have added the following:
#Override
protected void initBinder(HttpServletRequest pRequest, ServletRequestDataBinder pBinder) throws Exception
{
NumberFormat numberFormat = NumberFormat.getInstance();
pBinder.registerCustomEditor(Long.class, "qtyToShip", new CustomNumberEditor(Long.class, numberFormat, false));
}
Thanks
Perhaps error.code doesn't guarantee to return the most specific message code. Try to pass error message as a whole:
<spring:message message = "${error}" />

Resources