具有动态属性的Asp图像按钮 [英] Asp image button having dynamic attributes

查看:104
本文介绍了具有动态属性的Asp图像按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在右侧创建带有 - 的动态文本框(aspx图像按钮)



此部分

Creating dynamic textbox with "-" on the right (aspx image button)

this portion

RemoveA(this,' + value + ');

在我的调试模式下返回

RemoveA(this,' + value + ') 





需要推送价值,以便知道哪个文本框被删除等等。因此,我的网站体验页面验证问题。



in my debug mode.

Neccessary to push in the value, so as know which textbox is removed etc. Because of this, my website experience Page Validation issue.

 function GetDynamicFm(value) {
        var string1 = '<input name = "txtA' + value + '" id = "txtA' + value + '"  type="text" value = "" size="25" /> <asp:ImageButton ID="btnMinTextBox1" runat="server" ImageAlign="AbsMiddle" AutoPostBack="False" ImageUrl="../../img/minus_icon.png" onClientClick="RemoveA(this,' + value + ');return false;" ToolTip="Remove"/><input name = "hiddenAId' + value + '" id= "hiddenAId' + value + '" type="hidden" value=""/><input name = "hiddentxtA' + value + '" id="hiddentxtA' + value + '" type="hidden"/>';
}





我的尝试:



我尝试了很多方法。有时经历服务器形成不好



What I have tried:

I tried a lot of ways. Sometime experienced "the server not well formed"

推荐答案

没有必要从javascript创建动态asp控件,因为控件是从服务器处理并呈现为html元素在浏览器页面中,javascript不知道创建的元素的asp前缀。所以用html元素替换asp元素

There is no point of creating dynamic asp controls from javascript since the controls are processed from the server and rendered as html element in the browser page, The javascript is not aware of the asp prefix to the elements created. so replace the asp elements with the html element as
function GetDynamicFm(value) {
         var string1 = '<input name = "txtA' + value + '" id = "txtA' + value + '"  type="text" value = "" size="25" /> <img src="../../img/minus_icon.png" onclick="RemoveA(this,"' + value + '");return false;" title="Remove"/><input name = "hiddenAId' + value + '" id= "hiddenAId' + value + '" type="hidden" value=""/><input name = "hiddentxtA' + value + '" id="hiddentxtA' + value + '" type="hidden"/>';
         return string1;
     }

     var a = GetDynamicFm('-');





RemoveA(this,'+ value +') - 此代码仅在数字传递给函数时才有效,如果有任何字符串则会为无效参数抛出错误,所以最好在所有情况下将其作为字符串传递并相应地使用它





RemoveA(this,' + value + ') - this code will work only when a number is passed to the function, if there is any string then it will throw an error for invalid argument, so better pass it as string in all cases and use it accordingly

onclick="RemoveA(this,"' + value + '");


这篇关于具有动态属性的Asp图像按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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