I have written some code that uses a Button to redirect the user to another asp page. This button uses a hyperlink to direct the user. But I also pass variables in this string to the new ASP page, and in doing this I have a problem.
When a name is separated by a space as in
FirstName LastName you need to encapsulate the name with 'i.e. 'FirstName LastName'. But as soon as you do this the hyperlink no longer functions as it sees the first ' as the end of the string. Is there a solution to this problem?
The code for the Button is bellow
This works
<%'HString= "'./customer.asp?ID=1&Cust_Name=FirstName LastName"%>
<p align="center"><input type=button value="Change" onClick="location.href= <%=HString%>"></p>
This does not.
<%'HString= "'./customer.asp?ID=1&Cust_Name='FirstName LastName'"%>
<p align="center"><input type=button value="Change" onClick="location.href= <%=HString%>"></p>
When a name is separated by a space as in
FirstName LastName you need to encapsulate the name with 'i.e. 'FirstName LastName'. But as soon as you do this the hyperlink no longer functions as it sees the first ' as the end of the string. Is there a solution to this problem?
The code for the Button is bellow
This works
<%'HString= "'./customer.asp?ID=1&Cust_Name=FirstName LastName"%>
<p align="center"><input type=button value="Change" onClick="location.href= <%=HString%>"></p>
This does not.
<%'HString= "'./customer.asp?ID=1&Cust_Name='FirstName LastName'"%>
<p align="center"><input type=button value="Change" onClick="location.href= <%=HString%>"></p>