How can I write this code:
<script type="text/javascript" id="igClientScript"> function showModalWin(w) { var w = $find('<%= modalwindow.ClientID %>'); w.set_windowState($IG.DialogWindowState.Normal); } </script>
in a separate js file?.
Thaks.
The error message you're getting is different than the code in the client-side event handler of your WebImageButton. Either this was a typo, or the error is happening in a different location. Can you please confirm which?
The call to .js file is right because If I write only an alert("xxx") it works ok.
.js file :
showmodalwin = function(w) { //only for test = alert("xxx"); this works ok when I try it
w.set_windowState($IG.DialogWindowState.Normal);}
.aspx file:
...<ig:WebDialogWindow ID="modalwin" runat="server" Height="300px" InitialLocation="Centered" Width="400px" Modal="True" WindowState="Hidden"> <ContentPane>... </ContentPane></ig:WebDialogWindow>...
<igtxt:WebImageButton ID="b1" runat="server" AutoSubmit="False"> <ClientSideEvents Click= "showmodalwin($find('<%= modalwin.ClientID %>'));"/>
When I click on the button I get: Can't eval $find('<%= VFiltros.ClientID %>'));Debugging show that js file receive w as null
You need to use the $find() function to get a reference to your WebDialogWindow. You also need to use its client-side ID, which means that you need to have a reference to the control to get at it.
Assuming that the server-side ID of your WebDialogWindow instance is "modalwindow", and assuming that this control exists on the page where you've put this JavaScript code, I suspect the following is what you're after:
showModalWin($find('<%= modalwindow.ClientID %>'));
You also need to make sure that you have a SCRIPT element on your page, whose "src" attribute points to the file that contains your showModalWin() function. Given the "Can't eval showModalWin" error message, it's possible that your browser can't find the function to be able to call it.
The w parameter is becausse all the test I'm doing ...
The problem is that I don't know how to instance the object in the aspx page.
I tried with:
....showModalWin($find('" + modalwindow.ClientID + "')))"/>
....showModalWin(document.getElementByID('modalwindow'))"/>
etc, etc, etc ...
Always get the error : Can't eval showModalWin...
After this, I begun to try it without parameters, directly in js code, but without success
antfor said:It seems like the sintax $find('<%= modalwindow.ClientID %>' is not correct out of html code.
$find('<%= modalwindow.ClientID %>'
is not correct out of html code.
I notice that you already have "w" as a parameter in your function:
antfor said:function showModalWin(w)
With this in mind, you should get a reference to your WebDialogWindow first, then pass this reference as a parameter in your call your showModalWin() function. Your function would look like this:
<script type="text/javascript" id="igClientScript"> function showModalWin(w){ // var w = $find('<%= modalwindow.ClientID %>'); if (w && w != "undefined") w.set_windowState($IG.DialogWindowState.Normal);}</script>
The "if" statement is basically a check to make sure that you have some kind of object.