How to use a webservice with a Coolite window?

  1. #1

    How to use a webservice with a Coolite window?

    I'm using a web service to retrieve some dynamically formatted HTML and currently creates a javascript popup window to render the HTML. How can I do something similar with the Coolite Window control.


    Thanks,

    Brian
  2. #2

    RE: How to use a webservice with a Coolite window?

    Hi Brian,

    Just wondering if you can post some code to demonstrate how you are doing this currently? From there, it should be fairly easy to port that to use an <ext:Window>

    Geoffrey McGill
    Founder & CEO
  3. #3

    RE: How to use a webservice with a Coolite window?

    I'm making an directory of all employee's within my company using a dynamically created label and pulling position from a sql db to simulate employee office locations. I also add to that a onclick calling call_getdata.js. The call to the javascript goes out to the "EmployeeDirectory_v2.DL.srv_GetData.GetData" web service. Currently the javascript calls another javascript to create a popup window. Using the webservice I return "HTML" and inject it into the "succeededcallback" function which renders the popup and I get a nice little popup window displaying the details of an employee. I wish to use the coolite window instead and in future use the v.5 tools as well.....

    Thanks

    
    
    //BEGIN default.aspx
    //here is a sample of how I create the label and set there locations and click event
    For i = 0 To NumPoints - 1
    
    lbl = New Label()
    
    lbl.Text = empName(i)
    
    'lbl. = ID(i)
    
    lbl.Width = sX(i).ToString
    
    lbl.Height = sY(i).ToString
    
    lbl.Attributes.Item("style") = "cursor: pointer; text-align: center; font-size: x-small; font-family: Verdana; LEFT: " &amp; cX(i) &amp; "px; POSITION: absolute; TOP: " &amp; cY(i) &amp; "px"
    
    lbl.Attributes.Add("ID", ID(i))
    
    lbl.Attributes.Item("onclick") = "GetContent(" &amp; ID(i) &amp; ");"
    
    PlaceHolder1.Controls.Add(lbl)
    
    'Dim spacer As LiteralControl = New LiteralControl("<br>")
    
    'PlaceHolder1.Controls.Add(spacer)
    
    Next i//END-------------------------------------------------------
    
    //BEGIN------------------------------------------------------------------
    //call_getdata.js
    //I call this Javascript in an onclick event from a label
    
    
    
    function GetContent(x) 
    
    {
    
    EmployeeDirectory_v2.DL.srv_GetData.GetData(x, SucceededCallback);
    
    }
    
    function SucceededCallback(result, eventArgs)
    
    {
    
    //Page element to display feedback.
    
    
    
    
    
    xWindowContent = result;
    
    if (xWindowContent.match("xxx0")) 
    
    
    
    { 
    
    
    
    winnum = winnum + 1
    
    if(winnum == 1){
    
    xWindowContent = xWindowContent.replace(/xxx0/,"");
    
    
    
    createNewWindow(330,236,454,380,xWindowContent);
    
    
    
    }
    
    
    
    else
    
    {
    
    xWindowContent = xWindowContent.replace(/xxx0/,"");
    
    &#100;ocument.getElementById("dhtml_goodies_id" + divCounter).style.display='none';
    
    createNewWindow(330,236,454,380,xWindowContent);
    
    
    
    }
    
    }
    
    else
    
    {
    
    
    
    
    
    
    
    winnum = winnum + 1
    
    if(winnum == 1){
    
    xWindowContent = xWindowContent.replace(/xxx8/,"");
    
    
    
    createNewWindow(330,320,454,380,xWindowContent);
    
    
    
    }
    
    
    
    else
    
    {
    
    xWindowContent = xWindowContent.replace(/xxx8/,"");
    
    &#100;ocument.getElementById("dhtml_goodies_id" + divCounter).style.display='none';
    
    createNewWindow(330,320,454,380,xWindowContent);
    
    
    
    }
    
    }
    
    
    
    
    
    ;
    
    
    
    
    
    }
    
    
    
    
    
    if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();//END--------------------------------------------------
    
    //BEGIN----------------------------------------------
    //webservice
    
    
    
    Imports KSMEmployeeDirectory_v2.BL.scripts
    
    Imports System.Web
    
    Imports System.Web.Services
    
    Imports System.Web.Services.Protocols
    
    Imports System.Web.Script.Services
    
    Imports System.Web.Configuration
    
    Imports System.ComponentModel
    
    Namespace DL
    
    <WebService(Namespace:="KSMEmployeeDirectory_v2.DL.srv_GetData")> _
    
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    
    <ScriptService()> _
    
    Public Class srv_GetData
    
    Inherits System.Web.Services.WebService
    
    <WebMethod()> _
    
    Public Function GetData(ByVal wID As String) As String
    
    'Dim SQL As New SqlDataSource
    
    'SQL.ConnectionString = ConfigurationManager.ConnectionStrings("KSMPCInventoryConnectionString2").ToString
    
    'SQL.SelectCommand = "SELECT PC_info.Model, PC_info.CPU, PC_info.Memory, PC_info.FloppyDrive, PC_info.HardDrive, PC_info.Video, PC_info.DualMonitor, PC_info.ServiceTag, PC_info.ExpressServ, PC_info.Warranty, PC_info.SpecialUse, Matchup.workspaceid, Workspace.GenLoc, Workspace.PhoneExt, Workspace.DataPort1, Matchup.empid, Matchup.PcNumber, LTRIM(RTRIM(KSM.dbo.Employee.Empfname)) + ' ' + KSM.dbo.Employee.Emplname AS empname, PC_info.PcNotes, KSM.dbo.vExtension.EmpCustValue AS Extension, PC_info.UserStamp, PC_info.Type, PC_info.MonitorCount, KSM.dbo.Employee.Empdept, CONVERT (varchar(12), KSM.dbo.Employee.Emphire, 101) AS startdate, KSM.dbo.Employee.Empstatus, KSM.dbo.Employee.Empphone1 AS HomePhone, KSM.dbo.Employee.Empphone2 AS cell, KSM.dbo.Employee.Empnum, KSM.dbo.Department.DeptName, LEFT (LTRIM(RTRIM(KSM.dbo.Employee.Empfname)), 1) + LTRIM(RTRIM(KSM.dbo.Employee.Emplname)) + KSM.dbo.Employee.Empnum + '.jpg' AS EmpPic, KSM.dbo.Employee.EmpEmail, KSM.dbo.vOfficeFax.EmpCustValue AS fax, KSM.dbo.vEmpSchool.EmpCustValue AS School, LTRIM(RTRIM(KSM.dbo.Employee.Empfname)) AS FirstName, KSM.dbo.Employee.Emplname AS LastName, KSM.dbo.vEmpSpecialty.EmpCustValue AS Specialty, KSM.dbo.SkillLevel.SkDesc AS Partner, KSM.dbo.Employee.Empcity AS City, KSM.dbo.Employee.Empaddr1 AS Address, KSM.dbo.Employee.Empst AS State, KSM.dbo.Employee.Empzip AS Zip, KSM.dbo.vSpouse.EmpCustValue AS Spouse, Workspace.WorkspaceJacks FROM KSM.dbo.SkillLevel RIGHT OUTER JOIN KSM.dbo.Employee ON KSM.dbo.SkillLevel.SkID = KSM.dbo.Employee.Emplevel LEFT OUTER JOIN KSM.dbo.vEmpSchool ON KSM.dbo.Employee.ID = KSM.dbo.vEmpSchool.EmpCustEmpId LEFT OUTER JOIN KSM.dbo.vOfficeFax ON KSM.dbo.Employee.ID = KSM.dbo.vOfficeFax.EmpCustEmpId RIGHT OUTER JOIN KSM.dbo.Department ON KSM.dbo.Employee.Empdept = KSM.dbo.Department.DeptID LEFT OUTER JOIN KSM.dbo.vExtension ON KSM.dbo.Employee.ID = KSM.dbo.vExtension.EmpCustEmpId LEFT OUTER JOIN Workspace RIGHT OUTER JOIN Matchup ON Workspace.Workspaceid = Matchup.workspaceid RIGHT OUTER JOIN PC_info ON Matchup.PcNumber = PC_info.PCNumber ON KSM.dbo.Employee.ID = Matchup.empid LEFT OUTER JOIN KSM.dbo.vEmpSpecialty ON KSM.dbo.Employee.ID = KSM.dbo.vEmpSpecialty.EmpCustEmpId LEFT OUTER JOIN KSM.dbo.vSpouse ON KSM.dbo.Employee.ID = KSM.dbo.vSpouse.EmpCustId WHERE (Matchup.workspaceid = " &amp; contextKey &amp; ")"
    
    Dim KSMInventoryConnectionString As String = WebConfigurationManager.ConnectionStrings("KSMEmployeeDirectory_v2.My.MySettings.sql_empdir").ToString
    
    Dim cnSQL As Data.SqlClient.SqlConnection
    
    Dim prmSQL As Data.SqlClient.SqlParameter
    
    Dim drSQL As Data.SqlClient.SqlDataReader
    
    Dim cmdSQL As Data.SqlClient.SqlCommand
    
    ''Employee Information
    
    Dim empname As String = ""
    
    Dim DeptName As String = ""
    
    Dim emppic As String = ""
    
    Dim Specialty As String = ""
    
    Dim EmpEmail As String = ""
    
    Dim hmnum As String = ""
    
    Dim wkext As String = ""
    
    Dim cellnum As String = ""
    
    Dim faxnum As String = ""
    
    Dim Address As String = ""
    
    Dim City As String = ""
    
    Dim State As String = ""
    
    Dim Zip As String = " "
    
    Dim startdate As String = ""
    
    Dim School As String = ""
    
    ''IS Information
    
    Dim PCNumber As String = ""
    
    Dim Model As String = ""
    
    Dim ServiceTag As String = ""
    
    Dim jackID As String = ""
    
    Dim Warranty As String = ""
    
    cnSQL = New Data.SqlClient.SqlConnection(KSMInventoryConnectionString)
    
    cnSQL.Open()
    
    cmdSQL = New Data.SqlClient.SqlCommand("GET_EmpDirData", cnSQL)
    
    With cmdSQL
    
    .CommandTimeout = 60
    
    .CommandType = Data.CommandType.StoredProcedure
    
    prmSQL = .Parameters.Add("wID", Data.SqlDbType.Int)
    
    prmSQL.Value = wID
    
    drSQL = .ExecuteReader
    
    Do While drSQL.Read()
    
    ''Employee Information
    
    empname = drSQL("empname") &amp; " "
    
    DeptName = drSQL("DeptName") &amp; " "
    
    emppic = drSQL("emppic") &amp; " "
    
    Specialty = drSQL("Specialty") &amp; " "
    
    EmpEmail = drSQL("EmpEmail") &amp; " "
    
    hmnum = drSQL("hmnum") &amp; " "
    
    wkext = drSQL("wkext") &amp; " "
    
    cellnum = drSQL("cellnum") &amp; " "
    
    faxnum = drSQL("faxnum") &amp; " "
    
    Address = drSQL("Address") &amp; " "
    
    City = drSQL("City") &amp; " "
    
    State = drSQL("State") &amp; " "
    
    Zip = drSQL("Zip") &amp; " "
    
    startdate = drSQL("startdate") &amp; " "
    
    School = drSQL("School") &amp; " "
    
    ''IS Information
    
    PCNumber = drSQL("pcnumber")
    
    Model = drSQL("Model")
    
    ServiceTag = drSQL("servicetag")
    
    jackID = drSQL("jackID")
    
    Warranty = drSQL("warranty")
    
    drSQL.NextResult()
    
    Loop
    
    drSQL.Close()
    
    End With
    
    cmdSQL = Nothing
    
    cnSQL.Close()
    
    cnSQL.Dispose()
    
    Dim userid As Integer = GetUserID()
    
    Dim SysAdminLevel As String = GetPermission(userid, "IsDept")
    
    Dim x As String
    
    If SysAdminLevel >= "0" And SysAdminLevel < "8" Then
    
     
    
    x = "xxx" &amp; SysAdminLevel &amp; _
    
    "<table id='tbl_EmpDetails' width='280' border='0' cellpadding='0' cellspacing='0' style=';BORDER-RIGHT: navy 0px solid; BORDER-TOP: navy 1px solid; BORDER-LEFT: navy 1px solid; BORDER-BOTTOM: navy 0px solid;background-color: LightSteelBlue; background-image: url(images/New_Table_flattened.jpg);'>" &amp; _
    
    "<tr><td colspan='3' width='150' height='33'>&amp;nbsp;" &amp; _
    
    empname &amp; "</td><td colspan='4' width='200' height='33'>" &amp; _
    
    empname &amp; "</td></tr><tr><td style='background-image: url(images/EmpPicBg.gif);background-repeat: no-repeat;background-color:white;'rowspan='10' width='150' height='160'><img id='img_EmpDetails01' src='EmpPics\" &amp; _
    
    emppic &amp; "'" &amp; "style='border-color:DarkOrange;border-width:2px;border-style:solid;width:140px;' /></td><td colspan='6' width='164' height='25' valign='top'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    DeptName &amp; "</td></tr><tr><td colspan='6' width='164' style='height: 15px'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    "<a href='mailto:" &amp; EmpEmail &amp; "'>" &amp; EmpEmail &amp; "</td></tr><tr style='background-color:white;'><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Ext:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    wkext &amp; "</td></tr><tr><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Cell:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    cellnum &amp; "</td></tr><tr style='background-color:white;'><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Fax:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    faxnum &amp; "</td></tr><tr><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Hm:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    hmnum &amp; "</td></tr><tr style='background-color:white;'><td colspan='6' width='164' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    Address &amp; "</td></tr><tr style='background-color:white;'><td colspan='4' width='85' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    City &amp; "</td><td height='15' style='width: 15px'>" &amp; _
    
    State &amp; "</td><td width='15' height='15'>" &amp; _
    
    Zip &amp; "</td></tr><tr><td colspan='3' height='15' style='width: 15px'>" &amp; _
    
    "&amp;nbsp;&amp;nbsp;&amp;nbsp;Start Date:</td><td colspan='3' height='15' style='width: 76px'>" &amp; _
    
    startdate &amp; "</td></tr><tr style='background-color:white;'><td colspan='6' width='164' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    School &amp; "</td></tr><tr><td colspan='7' width='350' height='17'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    Specialty &amp; "</td></tr></table>"
    
    Else
    
    'with permission
    
    x = "xxx" &amp; SysAdminLevel &amp; _
    
    "<table id='FVEmp_geez' width='330' border='0' cellpadding='0' cellspacing='0' style=';BORDER-RIGHT: navy 0px solid; BORDER-TOP: navy 1px solid; BORDER-LEFT: navy 1px solid; BORDER-BOTTOM: navy 0px solid;background-color: LightSteelBlue; background-image: url(images/New_Table_flattened.jpg);'>" &amp; _
    
    "<tr><td colspan='3' width='150' height='33'>&amp;nbsp;" &amp; _
    
    empname &amp; "</td><td colspan='4' width='200' height='33'>" &amp; _
    
    empname &amp; "</td></tr><tr><td style='background-image:url(images/EmpPicBg.gif);background-repeat: no-repeat;background-color:white;'rowspan='10' width='150' height='160'><img id='FV109_ImgEmp' src='EmpPics\" &amp; _
    
    emppic &amp; "'" &amp; "style='border-color:DarkOrange;border-width:2px;border-style:solid;width:140px;' /></td><td colspan='6' width='164' height='25' valign='top'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    DeptName &amp; "</td></tr><tr><td colspan='6' width='164' style='height: 15px'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    "<a href='mailto:" &amp; EmpEmail &amp; "'>" &amp; EmpEmail &amp; "</td></tr><tr style='background-color:white;'><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Ext:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    wkext &amp; "</td></tr><tr><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Cell:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    cellnum &amp; "</td></tr><tr style='background-color:white;'><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Fax:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    faxnum &amp; "</td></tr><tr><td width='40' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Hm:</td><td colspan='5' width='124' height='15'>" &amp; _
    
    hmnum &amp; "</td></tr><tr style='background-color:white;'><td colspan='6' width='164' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    Address &amp; "</td></tr><tr style='background-color:white;'><td colspan='4' width='85' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    City &amp; "</td><td height='15' style='width: 15px'>" &amp; _
    
    State &amp; "</td><td width='15' height='15'>" &amp; _
    
    Zip &amp; "</td></tr><tr><td colspan='3' height='15' style='width: 15px'>" &amp; _
    
    "&amp;nbsp;&amp;nbsp;&amp;nbsp;Start Date:</td><td colspan='3' height='15' style='width: 76px'>" &amp; _
    
    startdate &amp; "</td></tr><tr style='background-color:white;'><td colspan='6' width='164' height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    School &amp; "</td></tr><tr><td colspan='7' width='314' height='17'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    Specialty &amp; "</td></tr></table>" &amp; _
    
    "<table id='FVEmp_geez' width='100%' border='0' cellpadding='0' cellspacing='0' style='background-image: url(images/lightblue.gif);background-color: LightSteelBlue;'>" &amp; _
    
    "<tr style='background-color:DarkOrange;'><td colspan='2' style='height: 15px'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    "IS Information</td></tr><tr style='background-color:white;'><td height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    Model &amp; "</td><td height='15'>" &amp; _
    
    "Connect to:&amp;nbsp;&amp;nbsp;&amp;nbsp;<a href='http://ksm16/ksminventory/vnc2.aspx?PCNumber=" &amp; PCNumber &amp; "' " &amp; ">" &amp; PCNumber &amp; "</td></tr><tr><td height='15'>&amp;nbsp;&amp;nbsp;&amp;nbsp;Service Tag:&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    ServiceTag &amp; "</td><td height='15'>" &amp; _
    
    "Workspace Jack:&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; _
    
    jackID &amp; "</td></tr><tr style='background-color:white;'><td height='15'>" &amp; _
    
    "&amp;nbsp;&amp;nbsp;&amp;nbsp;Warranty exp:&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; Warranty &amp; "</td><td height='15'>" &amp; _
    
    "Inventory for:&amp;nbsp;&amp;nbsp;&amp;nbsp;<a href='http://ksm16/ksminventory/ViewAllPcs2.aspx?Selectedpc=" &amp; PCNumber &amp; "' target='_blank'>" &amp; PCNumber &amp; "</td></tr><tr><td>&amp;nbsp;&amp;nbsp;&amp;nbsp;WkspID:&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; wID &amp; "</td></tr></table>"
    
    End If
    
    
    
    Return x
    
    End Function
    
    End Class
    
    End Namespace
    
    //END----------------------------------------------------------------------
  4. #4

    RE: How to use a webservice with a Coolite window?

    You're going to have to scale back that sample a bit. It takes an enourmous amount of time to try and piece together what's happening on that page and I was not able to get something working. If you have a sample a "little more to the point", I'm sure I can post a working solution.

    As a general rule of thumb, if forum members can simplify a sample/problem down to one self contained .aspx that we can quickly load into a testing project/site, you will get a detailed and quick response. The more time it takes for us to try to "figure out" and deconstruct a code sample, the less likely it will be that we can respond quickly.

    Personally, I also prefer when the server-side code is placed at the top of the same page, instead of in a separate code-behind or partial class. Including everything in one file just simplifies the process and keeps everything together.

    Example

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label1.Text = "This is a simple Page Template";
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Simple Page Template</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:Label ID="Label1" runat="server" />                                        
        </form>
    </body>
    </html>
    Geoffrey McGill
    Founder & CEO
  5. #5

    RE: How to use a webservice with a Coolite window?

    I thought that was alot of code for what I think is probably a simple solution. Basically I'm just trying to use a popup window and a webservice. I would like to eliminate a window rendered by javascript and focus more on your control. That large amount of code is what it took me just to have a popup window display data. I think with coolite popup not only am I eliminating the excessive code but I'm putting control back into Visual Studio. I you have a quick example how you would combine a web service and the window control I think this would allow my to figure out the rest. Sorry for the huge amount of code!

    P.S. The webservice is basically a SQL adapter that fires a Stored Procedure and return data. The way that data is handled when "posting back" to the page is what I'm stuck on the most.
  6. #6

    RE: How to use a webservice with a Coolite window?

    Was my simplification of code still unacceptable...I don't need any specific examples or alot of time devoted to this solution. With a good direction I can figure it out.


    Thanks again!

    Brian

Similar Threads

  1. Replies: 5
    Last Post: Jun 13, 2011, 9:48 AM
  2. Replies: 10
    Last Post: Apr 30, 2010, 6:42 PM
  3. Replies: 0
    Last Post: Nov 19, 2009, 12:50 PM
  4. Coolite window on AJAX page
    By jmilton in forum 1.x Help
    Replies: 0
    Last Post: Jun 25, 2009, 4:00 PM
  5. [CLOSED] Coolite Window Manager
    By skynet in forum 1.x Premium Help
    Replies: 13
    Last Post: Jun 25, 2009, 11:45 AM

Posting Permissions