ASP.NET How to pass container value as javascript argument -
I am experimenting with a template on a text box.
I want to pass an argument to a JavaScript, an existing line index of a grid when a user clicks on it.
but
onClick = 'setGridInEditMode (& lt;% # container. Result of record index%>); '/ & Gt;
comes out as
onClick = "setGridInEditMode (& amp; ###container.record index%>);"
Is there a way to pass the container value for JavaScript?
Here's the markup in question.
& lt; Cc1: Grid ID = "_trustgrid" runat = "server" folder style = "Styles / style_7" permission Dilling Records = "wrong" AllowSotting = "wrong" Allow PageSwapConclusion = "False" AllowGaganing = "Incorrect" AllowMultiardAditing = "True" auto generated column = "wrong" onupdateMand = "_trustgrid_update commmand" honorbind = "_trustgrid_rbind" & gt; & Lt; Columns & gt; & Lt; Cc1: Column AllowEdit = "true" permission by = "incorrect" header text = "edit" width = "130" run = "server" /> & Lt; Cc1: column datafield = "trustdocid" headerText = "trustdocid" width = "125" read-only = "wrong" allow = "false" TemplateId = "trustDocIDGridTemplate" /> & Lt; / Column & gt; & Lt; Templates & gt; & Lt; Cc1: GridTypePlat ID = "TrustDoDidGridGrammet Template" control id = "TB1" runat = "server" & gt; & Lt; Template & gt; & Lt; ASP: Text Box ID = "TrustDocuedTexbox" Runat = "Server" visible = "true" text = '& lt;% # container.value% & gt;' OnClick = 'setGridInEditMode (& lt;% # Container.Record Index% & gt;);' / & Gt; & Lt; / Template & gt; & Lt; / CC1: GridTemplate & gt; & Lt; / Templates & gt; & Lt; / CC1: Grid & gt; I used to call the second Darin to use the inefficient JavaScript. I
However, Does not answer your question why this is being done by ASP.Net.
The reason for it
onClick = "setGridInEditMode (& amp; ltd;% # container; Records index%>;);"
That's because the server does not interfere directly in the database in the database for control properties. It means, only property = "& lt;% # ...% & Gt; "
is allowed.
So in your case, you have to say what you want to do a roundabout fashion (though I personally think it is a bit clearer and more accomplished):
onClick = '& lt;% # String.Format ("setGridInEditMode ({0});", container. Record Indexes% & gt;
(See your single and double quotes!)
This limit applies to only server controls and their properties. It does not apply to the nested textual content of a server control (such as the templates or the bodies of panels) nor is there any other plain HTML used, which is probably why you have not seen it before.
Comments
Post a Comment