如何通过html调用c-sharp函数 [英] How to call c-sharp function by html

查看:108
本文介绍了如何通过html调用c-sharp函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int i;

       title = "";
       for (i = 0; i < ds.Tables[0].Rows.Count; i++)

       {

           title = title + "<div class='one' ><div class='Solar Mobile'><h1>" + (i + 1).ToString() + "." + ds.Tables[0].Rows[i]["product_name"].ToString() + " Just Rs." + ds.Tables[0].Rows[i]["price"].ToString() + "/-<asp:ImageButton ID='ImageButton1' runat='server' ImageUrl='~/images/cart.jpg' onclick='Addtocart' /></h1></div><div class='Solar-text' >" + ds.Tables[0].Rows[i]["description"].ToString() + "</div ><div class='img'><img  src='imggrab.aspx?ID=" + ds.Tables[0].Rows[i]["pk_product_id"].ToString() + "' /></div><div class='clr'></div></div>";
       }



是否正确...我正试图调用



is it correct ... i''m trying to call

Addtocart

函数,但是asp图像按钮不起作用...为什么这样...?
在此先感谢

function but the asp image button does not appers... why so...?
thanks in advance

推荐答案

将HTML注入页面是可以的,但是您不能将asp.net控件注入为内嵌html.

而是尝试将控件添加到父控件.
Injecting HTML to the page is alright, but you can''t inject an asp.net control as inline html.

Instead try to add controls to the parent control.


它不起作用.您可以使用Rosponse.Write方法呈现html,但不能呈现服务器控件(asp:ImageButton).我认为您正在尝试将商品添加到购物车中.请添加一个GridView控件并直接绑定表中的数据,然后尝试自定义网格.您可以在GridView模板列中完成所有这些样式操作.
It doesn''t work. you can render the html using Rosponse.Write method, but cannot render server controls (asp:ImageButton). I think here you are trying to add the item to a cart. Please add a GridView control and bind the data from table directly and try to customize the grid. You can do all these style things in GridView template columns.


这篇关于如何通过html调用c-sharp函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆