Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling client-sdie vbscript function in server control

Status
Not open for further replies.

meckeard

Programmer
Joined
Aug 17, 2001
Messages
619
Location
US
Can this be done?

I have a datagrid that allows for edits. When the record in question populates with the data and the customer moves from a particular asp:TextBox, I want to call a client-side vbscript function that does some calculations.

If not, I can go with javascript. But it's internal to the company and we use on IE, so compatability is not an issue.

Thanks.
 
You can add an attribute to the textbox for the event you wish to fire the function:

txtMyBox.Attributes.Add("onblur", "vbscript:SomeFunction()");

etc...

For adding this to the edit items of a datagrid, you'll need to add them in the OnItemDataBound event of the datagrid, and only when the ItemType == ListItemType.EditItem:

~~~~
switch(e.Item.ItemType)
{
case ListItemType.EditItem:
//Add your attributes here by referencing the objects
// directly
TextBox txtMyBox = (TextBox)e.Item.FindControl("txtMyBox");
txtMyBox.Attributes.Add("onblur", "vbscript:SomeFunction()");
break;
}//switch
~~~~

-paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top