473,394 Members | 1,870 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,394 software developers and data experts.

not showing in the html source

greetings people

I am new to Ajax and javascript, yet i have little time to learn it all. Question is:

i am using javascript to create my DOM Table and AJAX that returns a DataSet to my Javascript to fill information in the table. Code looks like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>

<script language = javascript>


function DoWork()
{
var val = "1";

_Default.GridData(val,Result);

}


function Result(response)
{
var tblHead = tbl.createTHead();
var headrow = tbl.insertRow();

var headcell = headrow.insertCell(0);

var selchk = document.createElement("input");
selchk.setAttribute("type","checkbox");
selchk.setAttribute("id","slctAll");
selchk.setAttribute("onclick","javascript:SelectAl lCheckboxes(this);");
headcell.innerHTML = "Select All";
headcell.appendChild(selchk);

var headcell2 = headrow.insertCell(1);
headcell2.innerHTML = "Company ID";

var headcell3 = headrow.insertCell(2);
headcell3.innerHTML = "Company Name";

var headcell4 = headrow.insertCell(3);
headcell4.innerHTML = "Type Of Company";

tblHead.appendChild(headrow);

// Continue from here

var rows = response.value.Tables[0].Rows.length;

for (var i = 0; i < rows - 1; i++)
{
var row = tbl.insertRow();

var cell0 = row.insertCell(0);
var chk = document.createElement("input");
chk.setAttribute("type","checkbox");
chk.setAttribute("id", "chk" + i);
cell0.appendChild(chk);

var cell = row.insertCell(1);
var lnk = document.createElement("a");
lnk.setAttribute("href","Companies.aspx?" + response.value.Tables[0].Rows[i].CompanyID);
lnk.setAttribute("target","_blank");
lnk.innerHTML = response.value.Tables[0].Rows[i].CompanyID;
cell.appendChild(lnk);

var cell2 = row.insertCell(2);
cell2.innerHTML = response.value.Tables[0].Rows[i].Name;

var cell3 = row.insertCell(3);
cell3.innerHTML = response.value.Tables[0].Rows[i].TypeOfCompany;
}
}

</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btn" onclick="javascript:DoWork();"/>

<table id="tbl">




</table>

</div>
</form>
</body>
</html>

............

When i click the button the table shows perfectly with all the information. The problem is i cannot see the update in the HTML Source i.e. the DOM table is empty. Therefore how can i manipulate certain rows or cells in the table that the user checked. or how can i check all the rows if the user wanted to select all rows. i guess the elements of type checkbox dont exist. An example of the selectallcheckboxes function is like this:

function SelectAllCheckboxes(spanChk){

var theBox = spanChk;
var elm = theBox.form.elements;

for (i=0;i<elm.length;i++)
{
if (elm[i].type == "checkbox" && elm[i].id != "filterChk" && elm[i].id != "slctAll")
{
if (elm[i].checked != theBox.checked)
{
elm[i].click();

}
}
}
}

Thanking u guys in advance

kind regards
Dec 25 '06 #1
2 1790
AricC
1,892 Expert 1GB
Did you leave out some of the code? I don't see any ajax.
Dec 25 '06 #2
Did you leave out some of the code? I don't see any ajax.

greetings

this is the code for the AJAX. Incase you need to know, i am using the Microsoft AJAX library and i am calling the AJAX method from javascript simply by classname.method which will be _Default.GridData(val,Result); which then passes the DataSet to a javascript Result(response) Function. (response in this case is the DataSet that i am using in javascript that i got from the ajax method).

[Ajax.AjaxMethod]
public DataSet GridData(string x)
{
SqlConnection connection = Connections.GetSqlConnection();

WebService.Service wService = new WebService.Service();

SqlDataAdapter adapter = new SqlDataAdapter("SELECT FieldName, HeaderText FROM Fields WHERE TableID = " + x + " AND IsDisplayed = 1 ORDER BY IsKey DESC", connection);

DataTable Dtbl = new DataTable();

adapter.Fill(Dtbl);

string tblName = Convert.ToString(wService.ExecuteSqlCommand("SELEC T TableName FROM Tables WHERE TableID = " + x, true));

string sqlstr = "SELECT ";

int y = 0;

// Generating Sql Statement
foreach (DataRow dr in Dtbl.Rows)
{
if (y < Dtbl.Rows.Count - 1)
{
sqlstr += dr["FieldName"].ToString() + ", ";

y++;
}
else if (y == Dtbl.Rows.Count - 1)
{

sqlstr += dr["FieldName"].ToString();
sqlstr += " FROM " + tblName;
break;
}
}

SqlDataAdapter dAdapter = new SqlDataAdapter(sqlstr, connection);

DataSet ds = new DataSet();

dAdapter.Fill(ds);

return ds;
}
Dec 25 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: david | last post by:
Hello, i have html form for the user to input some french text. The text go in a mysql database * before: (mozilla-1.5) All my pages were designed to show themselves with the iso-8859-15...
1
by: Merijn Boom | last post by:
Hi, I would like to know is somebody has experience in showing HTML from a perl executable in the default browser and let that html interact with the perl executable via the browser. This is...
2
by: Alex Rybalov | last post by:
Hi, Using IIS 5.0 and sometime some asp pages (absolutely randomly) showing as blank white pages. So far only one way of fixing it - restart whole server. Restarting IIS, or specific web server...
1
by: news8080 | last post by:
I downloaded a GUI for nagios that uses PHP but when I point the browser at the PHP file, it shows me the source of .php file instead of executing it, if i use command line 'php filname.php'...
5
by: gregmercer | last post by:
I have the following html sample, where I'd like to have a show and hide two divs, one replacing the other. Following these two divs is a third div (the bluediv) which I would like to have placed...
9
by: Alex D. | last post by:
Hi, I have a frame in one of my pages that I use to show diferent pages each time. I am experiencing an weird behaviour in Mozilla and Firefox, when the frame's source is specified in the server...
5
nmm32
by: nmm32 | last post by:
I have a DataGrid which displays data with the aid of a procedure. I have tested the procedure inside the database and it is working fine. I have another procedure which adds another row to the...
1
by: dosingh | last post by:
i've put this page together using asp, html, javascript amd flash. java passes a number of variables over to the flash file but the flash graph does not appear. The error which appears is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.