Could someone tell me why this is happening and how to fix it if possible?
I have a button in a aspx file like:
<% foreach blah %.
orderID = GenerateCorrectOrderID();
<input id="btnOrder" type="button" style="background-color: #000040; color: #FFFFFF; font-weight: normal" value="Order" onclick="javascript:OpenOrderService('<%=orderID%>','A');" />
<% end foreach blah %>
The orderID is being placed correctly in the html as expected. I would like to replace the input button with a asp.button like this:
<asp:Button ID="btnOrder" style="background-color: #000040; color: #FFFFFF; font-weight: normal" Text="Order" OnClick="UpdateOrderGrid" runat="server" CausesValidation="False" Visible="False" onclientclick="javascript:OpenOrderService('<%=#orderID%>','A');" />
The <%=#orderID%> is not being properly placed in the html file. In fact it looks just like this: <%=#orderID%> How can I force it to inline properly?
Any idea on how I can get this to work? I really want to use a Asp.Button because I have a trigger in a update panel that it is attached to.
答案 0 :(得分:0)
If it were me, I would use a repeater and databind the onclientclick instead of putting the code in your aspx/ascx file.
If you MUST do it this way, it appears you've mixed databinding syntax with inline evaluation syntax.
What I think you want is
... onclinentclick="javascript:OpenOrderService('<%= orderId %>','A');" />
答案 1 :(得分:0)
那么尝试了几种不同的方法,比如java脚本类和什么不是....我决定使用一个输入按钮,我可以使用一些内联代码来定义它的id。然后我将一个asp.button放在一个不可见的div中,然后当按下输入按钮时,我会调用asp.button的click事件,这反过来会导致更新面板的触发器被触发。
我知道这是一种非常丑陋的方式,但我花了太多时间寻找更优雅的方法来实现这一目标。