tags:

views:

51

answers:

2

In the following code snippet I'm trying to set the setPrice argument dynamically.

XHTML:

<asp:DropDownList ID="CCType" 
                  runat="server" 
                  onchange="setPrice('<%# Eval("setPriceVal") %>')" 
                  TabIndex="16">
</asp:DropDownList>

Code Behind:

Dim setPriceVal As Literal = CType(FindControl("setPriceVal"),Literal)
setPriceVal.Text = "0"

I get an error saying the server tag is not well formed.

Have I gone about this the wrong way or is there a syntax error I can't see?

A: 

I believe it's:

<asp:DropDownList ID="CCType" 
                  runat="server" 
                  onchange='<%# setPrice(Eval("setPriceVal"))%>' 
                  TabIndex="16">
</asp:DropDownList>
Sean
A: 

You cannot add the server tags <%%> inside the tag of a runat=server tag unless it's in a Template control of some kind.

You can however, do what you want to do here by attaching an event handler from the code-behind.

SirDemon