开发者

Control the Name Attribute within an ImageButton using code-behind

开发者 https://www.devze.com 2023-02-28 04:12 出处:网络
I have an ImageButton which I want to change the NAME attribute of in the code-behind so that I can render the HTML as needed.

I have an ImageButton which I want to change the NAME attribute of in the code-behind so that I can render the HTML as needed.

The current Rendering is :

<input id="MainContent_GridViewTracking_ibOrderDetail_15" class="smIcon" type="image" src="../Images/icons/img_开发者_运维技巧page.png" text="Details" name="ctl00$MainContent$GridViewTracking$ctl17$ibOrderDetail">

I would like to control the NAME using code-behind as assign it to track.myID which would result with something like

<input id="MainContent_GridViewTracking_ibOrderDetail_15" class="dhIcon" type="image" src="../Images/icons/doc_page.png" text="Details" name="1654874">

TIA


Have you tried MyImageButtons.Attributes["name"]=xyz? Should to the trick. Or you could add any other attribute to it like so: MyImageButton.Attributes.Add("trackID", xyz) and use that atribute for whatever you want to use. Or if you don't want to use that other attribute you could use jQuery to grab that other attribute's value and set it as name value.


put runat="server" in the html, then you'll have access to it in the codebehind.

like:

<input id="MainContent_GridViewTracking_ibOrderDetail_15"
       runat="server"
       class="smIcon" 
       type="image" 
       src="../Images/icons/img_page.png" 
       text="Details" 
       name="ctl00$MainContent$GridViewTracking$ctl17$ibOrderDetail">
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号