Attributes.Add to textbox

G

Guest

Hi,

I have a datalist with a textbox control used for entering the qty for a
products, when I click it I would like the qty to clear. I added the
following in the ItemCreated sub of the datalist ;

Dim tmpTextBox As TextBox
tmpTextBox = CType(e.Item.FindControl("txtQty"), TextBox)
tmpTextBox.Attributes.Add("onfocus", "this.value='';")


This works fine in firefox , but not with internet explorer... is there any
reason why ?

Thanks

Neil
 
G

Guest

Howdy,

Could you please paste aspx code as well. Are you using validation controls
by any chance? I checked the code and it should work in both browsers.

Regads
 
N

Neil Steventon

Hi ,

I managed to find the problem in the end. There was one of our developers
who added some code into a master page to provide a highlighted input
feature. The code he added was so it worked in IE.

For Reference here is his code ;

<script type="text/javascript">
sfFocus = function() {
var sfEls = document.getElementsByTagName("INPUT");
for (var i=0; i<sfEls.length; i++) {
sfEls.onfocus=function() {
this.className+=" sffocus";
}
sfEls.onblur=function() {
this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);
</script>

This is what was playing me up, but took me a while to spot it.

Thanks for replying to the post.

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top