Rickzzz
asked on
ASP Control - Change Attribute Dynamically from VB.Net result
Need to change an attribute on an asp control based on the result of a vb.net query. My feeble stab at it is below. Can someone assist on the correct way? Thanks!!
<td><asp:TextBox ID="HomePhone" MaxLength="12" runat="server" TabIndex="4" <%If not errormsg = "" Then %>BorderColor="#990033"<%E nd If %> /></td>
<td><asp:TextBox ID="HomePhone" MaxLength="12" runat="server" TabIndex="4" <%If not errormsg = "" Then %>BorderColor="#990033"<%E
ASKER
I'm not using a codebehind page. How would I do that just wrapped in <% %>
If the control is blank then 'errormsg' is populated:
<%
If Request.Form("submit") = "Next" Then
Dim is_ok = True
If Request.Form("HomePhone") = "" Then
is_ok = False
errormsg = errormsg & "Home Phone is required<br />"
End If
%>
The user returns to the form and that error message is written out above the form.
I also want to 'light up' the Home Phone control so the user can easily focus on it. There is other required information as well gathered in the form.
This is obviously incorrect, but shows want I want to do:
<td><asp:TextBox ID="HomePhone" MaxLength="12" runat="server" TabIndex="4" <%If not errormsg = "" Then %>BorderColor="#990033"<%E nd If %> /></td>
Just trying to find out how to do this correctly.
Thanks!!
If the control is blank then 'errormsg' is populated:
<%
If Request.Form("submit") = "Next" Then
Dim is_ok = True
If Request.Form("HomePhone") = "" Then
is_ok = False
errormsg = errormsg & "Home Phone is required<br />"
End If
%>
The user returns to the form and that error message is written out above the form.
I also want to 'light up' the Home Phone control so the user can easily focus on it. There is other required information as well gathered in the form.
This is obviously incorrect, but shows want I want to do:
<td><asp:TextBox ID="HomePhone" MaxLength="12" runat="server" TabIndex="4" <%If not errormsg = "" Then %>BorderColor="#990033"<%E
Just trying to find out how to do this correctly.
Thanks!!
try this code below
HomePhone.Attributes.Add(" value", "your dynamic content");
HomePhone.Attributes.Add("
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<script type = "text/javascript">
<!--
function hide(x) {
document.getElementById(x) .style.dis play='none ';
document.getElementById(x) .value='';
}
function show(x) {
document.getElementById(x) .style.dis play='';
}
//-->
</script>
<!--
function hide(x) {
document.getElementById(x)
document.getElementById(x)
}
function show(x) {
document.getElementById(x)
}
//-->
</script>
if so you can do this on codebehind:
HomePhone.Attribute.Add("M
you can also remove attributes:
HomePhone.Attribute.Remove