This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Accessing Aras JavaScript method in Dot Net Application.

markW - Sunday, April 26, 2009 1:08 AM:

Is there any possible way to access the Aras JavaScript methods in ASP.NET, C# page. If so, how to call them in dot net applications.

Scenario:

I am opening an ASP.Net page containing a Treeview control inside a frame of an Aras Form. By clicking on the nodes of the Treeview control I wanted to open an instance of the selected node’s item type, which is there in the Aras Framework. In case of Aras,

To open an instance of an item type in a separate window, we are using a method, top.aras.uiShowItemEx (result.getItemByIndex(0).node,"tree view",true);

Since this method I am able to use only in Aras framework I am having an issue opening an instance of an item type by clicking on the Treeview node(the click event fires in asp.net) So the question is can we call Aras Javascript methods in my asp.net, C# pages. Since if I can use this Aras method I can open any instance from my ASP.NET.

A quick reply will be much appreciated.

Thanks.

Mark



PeterSchroer - Monday, April 27, 2009 9:35 AM:

Hello Mark,

Not clear to me...   is your ASP.NET application with the Treeview control running inside the Aras Innovator framework inside the standard Aras client,  or is this a separate client application,   independent of the Aras standard client.    If you are inside the framework,  just in a different frame,  you should be able to reach the top.aras  object for opening windows.    If you are outside the Aras client,  then you need to make a call to the Innovator server to have it place the Item you want to view (and the top.aras object) into the new frame.

peter



SamsAn - Thursday, April 30, 2009 7:40 AM:

If you use "Aras.Client.Controls.TreeGridContainer" as Treeview control you can assign javascript handler to GridClick (for example) event.
You should put html like below into the frame of the Aras Form where Treeview control is contained.
  <script type="text/javascript" for="treeviewControlName" event="GridClick(rowId, col)">
    top.aras.uiShowItemEx(result.getItemByIndex(0).node,"tree view",true);
  </script>
If you use a third-party company control, it should be possible assign javascript handler in similar way.

SamsAn.
Original Mind Any Level Innovator Solutions, http://sites.google.com/site/caraacc



markW - Saturday, May 2, 2009 4:57 PM:

Hello Peter,

We are inside the Aras Framework, just in a different Frame.  Basically there is frame where the ASP loads inside the Aras form.  We can get the Aras "Parent" to read items inside our Frame (ie, ASP Text box), but can't seem to do the reverse.  It may be as simple as we have the wrong syntax for accessing the parent, so if you have any small example of calling one of the client javascipt functions from a child frame (uiShowItemInFrameEx or anything of the like) that would be helpful.  We may have scenarios for doing it outside the Framework so I will experiment with the suggestion above also.

From your respones it sounds, like what we are trying to do is possible, so seems like it can be worked out.

Thanks,


Mark



markW - Saturday, May 2, 2009 5:01 PM:

Thanks Sams,

We will experiment with this.  I think what we tried is close to this, but we may have been missing the getItemByIndex call.  I have to check.

Mark



PeterSchroer - Monday, May 4, 2009 8:25 AM:

Mark,

Take a look at the  Variants Package on the communty projects web site.     There are versions for 8.2, 9.0 and 9.1  uploaded there.   Specifically,  look at the v_order Form.     On this form I have the Tabs disabled,  and have inserted 2 HTML fields,  each with a TreeGrid.    There is lots of JS functions that move data from/to the parent Item,  and also between the 2 tree controls.     All of the Innovator client API is available as  top.aras in this window,  and you can easily address the api's of either tree,     actually is quite simple as the whole object model is exposed just within the Form context.  

Peter



markW - Sunday, May 10, 2009 3:58 PM:

Hello Peter,

It looks like in Variants you are accessing the parent directly from the HTML sections.  We were able to make this work.  Our issue is when we have an iframe inside the HTML section which has a url to our asp.net page as follows:

<html>
<head>
<title>Mapping</title>
<script type="text/javascript">
</script>
</head>
<body>
<table>
<tr>
<td>
<iframe src="localhost/.../frmTreeMap.aspx" id="frmTest"  width="1100px"  height="550px"></iframe>
</td>
</tr>
</table>
</body>
</html>

We are able to read from the parent Aras form a text box value (in a hidden text box) of the asp.net code.  But, can't seem to do the reverse. 

We have created an ugly (but effective) work around, where we build a timer in a 2nd html section.  Every time the timer expires we run javascript in the 2nd html section to look for a value (the id of the Aras Item we want to open the form for) in the hiddent text box of our asp page.  If the value is found we open the Aras form with:

top.aras.uiShowItemEx(result.node,"tree view",true);   (See 2nd html code at bottom)

This works, but is obviously not the cleanest solution.  We would like to call the command directly when on an Event in our ASP page (instead of writing to the hiddent text box).

Likely this is just a syntax issue (or there is some windows security prevention which makes it impossible).  Seems like the latter is not the case, but we haven't found the right command structure for call the uiShow command from inside our frame.  My suspicion is there is a way, so if you have any suggestions it would be appreciated.

Thanks,

Mark

 

<!-- saved from url=(0013)about:internet -->
<html>
<head>
<script language="javascript" type="text/javascript">
setInterval("ShowMsg()",1000);
function ShowMsg()
{
try
{
document.getElementById('txtDisp').value = document.frames['frmTest'].document.getElementById('txtLatitude').value;

InstanceID();
}catch(e){}
}

function InstanceID()
{

//alert('Welcome');

var myTextField = document.getElementById('txtDisp');

     if(myTextField.value !== '')
     {
      var treeSelected= myTextField.value;
      var listtreeSelected =treeSelected.split("#");
      var innovator = new Innovator();
      var formNd = innovator.newItem(listtreeSelected[1], "get");
      var formId = listtreeSelected[0];  
      formNd.setID(formId);
     var result = formNd.apply();
    top.aras.uiShowItemEx(result.node,"tree view",true);
myTextField.value='';
document.frames['frmTest'].document.getElementById('txtLatitude').value='';
 
     } 

  
}


</script>
</head>
<body>
<input type="text" id="txtDisp" value=""  >
</body>
</html>