I'm trying to run some javascript with an event handler. Here is my code:
Protected Sub RecordBottomGridRow (ByVal as this object, ByVal e EventArgs) as handle GridView_Body.PageIndexChanging dim scriptText New StringBuilder () scriptText.Append ( "the & as lt, script type = "" text / javascript "" & gt; ") scriptText.Append (Environment.NewLine) scriptText.Append (" function RecordBottomGridRow () { ") scriptText.Append (Environment.NewLine) scriptText. Append ( "var element = document.getElementsByClassName ( 'XP');") script text .Append (environment. NewLine) scriptText.Append ( "var expIndex;") scriptText.Append (environment. NewLine) scriptText.Append ( "( Var i = 0, IM = for elements A length; im; i; i ++) {"} scriptText.Append (Environment.NewLine) scriptText.Append (" var elementId = Elements [i] .id; ") scriptText.Append (Environment.NewLine ) scriptText.Append ( "ExpIndex = elementId.substring (3);") script text .Append (environment. NewLine) scriptText.Append ( "}") scriptText.Append (Environment.New line) scriptText.Append ( "var fundCode = Document.getElementById ('htmlFund' + expIndex); "scriptText.Append (Environment.NewLine) scriptText.Append (" eu = document.getElementById ('exp' + expIndex); ") ScriptText.Append (environment. NewLine) scriptText.Append (" document.getElementById ( 'lastfundChosen') = fundcode.value; ") scriptText.Append (environment. NewLine) scriptText.Append (" document.getElementById ( 'expOrColl' ) .Value = e.value; ") scriptText.Append (Environment.NewLine) scriptText.Append (" Warning (e.value); ") scriptText.Append (Environment.NewLine) scriptText.Append ("}
Note that" there is a warning at the end "I run the code and fire the event, but populate a warning window to suggest JavaScript code. I am not doing wrong.
You declare the code as a function, in a nutshell It adds to your page output:
function RecordBottomGridRow () {.....}
You must add a client-side code that actually Name this function by name:
recordbottomgrid ();
In your case, you can copy the line
scriptText.Append ("} gt;")
(to follow your format):
scriptText.Append ("}") scriptText.Append (EnvironmentalNewLine) scriptText.Append (" RecordBottomGridRow ();
This code completes the declaration with block "}" and then to actually implement it on the client Connects the call.
Comments
Post a Comment