This is a migrated thread and some comments may be shown as answers.

[Solved] OnLoad javascript will not work

2 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Carmo
Top achievements
Rank 1
Daniel Carmo asked on 08 Dec 2010, 10:52 PM
Hello,

I am trying to get an onload event to work within a grid for a textbox that I am rendering.

I have the following code within a grid:

columns.Template(o =>
            {%>
                <% String functionCall = String.Format("checkChanged({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}')", "this" , o.Active ? "true" : "false", o.Percentage, o.BlockAdSource, o.UrlOverride, o.GroupName, o.DomainName, o.EnablePercentage); %>
                <% string functionPercentValidation = String.Format("validPercent({0},'{1}','{2}','{3}')", "this", o.UrlOverride, o.GroupName, o.DomainName); %>
                <%= Html.TextBox(o.UrlOverride + o.GroupName + o.DomainName, o.Percentage, new { onload = functionCall, onkeypress = "return disableEnterKey(event)", onkeyup = functionPercentValidation })%>
<%}).Title("Percentage");

So when the text box is rendered I want to be able to tell it wheither it should be active or deactivated with the checkChanged function. I know that this function works as I have it implemented on a checkbox with an onClick event which will deactivate or activate the text box based on the checkbox's value. I have also changed the function to an onblur event, and this works fine this way, so this is how i know that it is the onload event that isn't working, not my javascript. I cannot seem to get this onload event to work? Any suggestions?

Thanks,
Daniel     

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 09 Dec 2010, 10:36 AM
Hi Daniel,

I'm afraid that onload event is not applicable for input html elements.  Therefore, you should consider different approach to achieve the needed functionality, for example by disabling the input element through server code - adding the disabled attribute.

Greetings,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Daniel Carmo
Top achievements
Rank 1
answered on 13 Dec 2010, 05:54 PM
Hello and thank you for the response,

it's no big deal I have a work around already for the situation which is just resolving it within the table which it should be (just a bunch of if statements which I was hoping to eliminate with this little javascript. Not a huge fan of the post back's to the server IMO the if statements are probably faster than a post back on 100+ entries. It's very miss leading that VS2008's Intellisense includes the onload event in it's list for the input tags.

Thanks again,
Daniel
Tags
Grid
Asked by
Daniel Carmo
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Daniel Carmo
Top achievements
Rank 1
Share this question
or