Re: Call API from server side dropdownlist control

pinTab

Call API from server side dropdownlist control


tiobst 07-12-2006, 3:26

I need to call a function on a tab item page from a server side asp dropdownlist SelectedIndexChanged event on the main page.  I have used some of the code from the evaluation examples but have not gotten it to work.

On the main page:

There is a call button defined as follows:

function call() { var item = __objPinTab1.getTabItemByIndex(4); item.call("updateplans()"); }

<INPUT id="callbutton" type="button" value="Call" onclick="BLOCKED SCRIPT call()" style="Z-INDEX: 103; LEFT: 33px; POSITION: absolute; TOP: 504px"
   Height="30" Width="102">

The dropdownlist SelectedIndexChanged event has the following to click the call button:

System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript""defer>" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("document.getElementById('callbutton').click();" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("window.document.forms(0).submit();" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")

...

When I change the dropdownlist, I get the following error:

__objPineTab1 is null or not an object

I am sure the problem is due to server vs. client side processing, but I need to be able to call a function on the tab item page from a change in the dropdownlist.  The dropdownlist is also performing other functions other than calling the call button.

Thanks for your help.

 

 

 

 

 

Re: Call API from server side dropdownlist control


tiobst 07-12-2006, 3:53

I think I came up with a solution.  In the main page load I added:

ddlGroup.Attributes.Add("OnChange", "call();")

to call the function directly instead of using the call button.

Re: Call API from server side dropdownlist control


Pintexx Support 07-13-2006, 9:01

Hi,

your code is
var item = __objPinTab1.getTabItemByIndex..

The error message says:
__objPineTab1 is null or not an object

Is the control name PinTab1 or PineTab1 ?

I don't think that this will work:
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript""defer>" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("document.getElementById('callbutton').click();" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("window.document.forms(0).submit();" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")

It seems that this code is executed after loading the page ?

I would suggest to add a HTML dropdown to the page and use the onchange event to call "call".

Regards,
Hans-Peter