473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ATLAS / WEBSERVICES / C# / JAVASCRIPT / SQL SERVER

I wrote a pretty neat website today that can utilize no postback
AJAXIAN type features.

Basically to populate a drop down with a web service call that hits a
SQL server, based off the change of another drop down.

[.aspx file]

<%@ Page Language="C#" Title="Call Update" AutoEventWireup="true"
CodeFile="UpdateCall.aspx.cs" Inherits="Call_UpdateCall" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="../Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="updateform" runat="server">
<atlas:ScriptManager ID="scriptManager" EnablePartialRendering="true"
runat="server">
<Services><atlas:ServiceReference Path="~/Services/CallInfo.asmx"
/></Services>
</atlas:ScriptManager>
<div>
<span style="font-size: 12pt"><strong>Call Update -
</strong></span>
<asp:Label ID="lblCallNo" runat="server" ForeColor="#FFFF66"
Text="#####" Font-Bold="True" Font-Italic="False"
Font-Size="12pt"></asp:Label>&nbsp;<br />
<br />
Organization
<asp:DropDownList ID="ddlOrgs" runat="server"
DataSourceID="SqlDataSource1" DataTextField="USER_NAME"
DataValueField="USER_NAME">
</asp:DropDownList><br />
<br />
Product
<asp:DropDownList ID="ddlProduct" runat="server">
</asp:DropDownList><br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SHDDBConnectionString %>"
SelectCommand="SELECT DISTINCT USER_NAME FROM PEOPLE ORDER
BY USER_NAME"></asp:SqlDataSource>
</div>
</form>

<script type="text/javascript">

function populateProducts()
{
System.Issltd.Helpdesk.CallInfo.GetOrgs("SELECT
PRODUCT.PRODUCT_NAME FROM PEOPLE RIGHT OUTER JOIN PRODUCT ON
PEOPLE.USER_CODE = PRODUCT.PRODUCT_USERCODE WHERE PEOPLE.USER_NAME = '"
+ document.updateform.ddlOrgs.value + "'", OnRequestComplete);
}

function OnRequestComplete(result)
{
var r;
var resultArray = result.split("|");
var orgs = document.updateform.ddlProduct;
ClearList(orgs);
for (r = 0; r < resultArray.length; r++)
{
orgs.options[orgs.options.length] = new
Option(resultArray[r], resultArray[r], false, false);
}
}

function ClearList(list)
{
for (x = list.length; x >= 0; x--)
{
list[x] = null;
}
}

</script>
</body>
</html>

[.aspx.cs]

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Call_UpdateCall : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblCallNo.Text = Request.QueryString["inp_call_id"];
ddlOrgs.Attributes.Add("onChange", "populateProducts()");
}

}

[.asmx]

<%@ WebService Language="C#" Class="System.Issltd.Helpdesk.CallInfo" %>

using System.Configuration;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
using System;

namespace System.Issltd.Helpdesk
{

[WebService]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class CallInfo : System.Web.Services.WebService
{

[WebMethod]
public String GetOrgs(String query)
{
string errorMessage = "";
string dataConcat = "";
//Connection string is stored
//in the web.config file as an appSetting
string connectionString =
ConfigurationManager.ConnectionStrings["SHDDBConnectionString"].ConnectionString;
SqlConnection dbConnection = null;
// Open a connection to the database
try
{
dbConnection = new SqlConnection(connectionString);
dbConnection.Open();
}
catch (Exception ex)
{
errorMessage = ex.Message;
}
if (errorMessage == "")
{
// Build an insert command
string SQL = query;
SqlCommand SqlCmd = new SqlCommand(SQL, dbConnection);

try
{
SqlDataAdapter SqlDA = new SqlDataAdapter();
SqlDA.SelectCommand = SqlCmd;
DataSet ds = new DataSet();
SqlDA.Fill(ds);
foreach (DataRow dataRow in ds.Tables[0].Rows)
{
dataConcat = dataConcat + "|" +
dataRow[0].ToString();
}
dataConcat = dataConcat.Substring(1);
dbConnection.Close();

}
catch (System.Exception ex)
{
errorMessage = ex.Message;

}
finally
{
dbConnection.Dispose();
}
}
return dataConcat;
}
}
}
Let me know if you have any questions... Now I'm trying to reuse the
javascript code for many controls. Let's see what happens.

Sep 14 '06 #1
0 1391

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rogersmail | last post by:
Greetings to all, Can anyone tell me if Atlas can work directly with C# classes not defined as a webservice. sort of like a servlet class. I would like to create a thin and thick client for...
1
by: sales | last post by:
Hi Does ATLAS support the use of external javascript va this syntax --myPage.aspx-- atlas:ScriptManager ID="ScriptManager1" runat="server"> <Services> <atlas:ServiceReference...
1
by: amit | last post by:
Hi. I want to implement a right click context menu using Atlas for a web app. The page will list some usernames. Right clicking on a username needs to send the user name to a webservice,...
2
by: A.Wussow | last post by:
Hi Everybody, i want to load dynamically content from some user controls (with forms, or some data-controls) using atlas. So i use an UpdatePanel for loading the user control into a placeholder....
3
by: Marshall | last post by:
Hello, I am wondering if it is possible to call a remote web service using ATLAS and if so, how. I have read several docs which show how to call a web service that is within the same project as...
1
by: MPA | last post by:
Hi, I am a newbee to web applications and we are planning to rewrite our existing PowerBuilder client-server application into a web application under Visual Studio .Net 2005. My question is...
2
by: Tina | last post by:
I'm trying to get started with Atlas and associated necessary javascript at the same time. I started out at http://atlas.asp.net/walkthroughs/gettingstarted/basic.net where they have an...
4
by: Brad Baker | last post by:
I'm trying to implement a gridview control using atlas & asp.net per the following article: http://weblogs.asp.net/scottgu/archive/2005/12/26/433997.aspx My frustration is that the page I've...
1
by: jmdolinger | last post by:
Hi all, I'm a newbie to Atlas (and recently ASP.NET) after coming from a long Java background, also have done quite a bit with an Ajax.NET/ASP.NET 1.1 project, but it was basically all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.