Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Guidance... Update recordset from Textbox.value

Status
Not open for further replies.

zishan876

Programmer
Mar 19, 2007
61
US
Hi all:
I am new to ASP.NET (VB side )
But I have javascript code plus SQL Database connection and need to update the recordset with the value it populates into 2 textboxes.
Now I have no idea how to do that .... Can someone help..
Below is the structure to my code on my ASP page
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
<%@ Import Namespace="System" %>

<%@ Import Namespace="System.Data" %> 
<%@ Import Namespace="System.Data.SqlClient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL] 
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]

<head runat="server"> 
<script type="text/javascript">

var lat;

var longi;

function addM() 
{

document.getElementById("gf"').value = lat ; 
document.getElementById("fg").value = longi ;

}

function showLocation(address) 
{
addM(address);
Blah blah;

}

</script>

 

<title>Untitled Page</title> 
</head>

<body onload="initLoader();"> 
<script runat="server">

Sub Page_Load() 
Dim objConnect As SqlConnection

Dim objCommand As SqlCommandDim objDataReader As SqlDataReader 
 
objConnect = New SqlConnection(connectionString:="Server=XXX;Database=XXX;uid=XX;password=XX") 
 

objConnect.Open()

objCommand = New SqlCommand("Select LocationId,XXX,YYY,(Rtrim(SF_STREET) + ',' + RTRim(SF_City) + ',' + RTrim(SF_State) + ' ' + RTrim(SF_Zip)) As 'Address' from SF_Locations where LocationId=110", objConnect) 
objDataReader = objCommand.ExecuteReader()


'Start the form here

Response.Write("<form id=""form1"" action=""#"" onsubmit=""showLocation(); return false;"">")

Response.Write("<p>")

Response.Write("<b>Click on the Address to see Latitude and Longitude:</b>")

''Loop through the recordset

While objDataReader.Read() 
Response.Write("<a href=""javascript:void(0)"" onclick=""showLocation('" + objDataReader("Address") + "');return true;"">" + objDataReader("Address") + "</a>")

Response.Write("<input id=""gf"" type=""text"" value=""0"" />")

Response.Write("<input id=""fg"" type=""text"" value=""0"" />")


End While

Response.Write("<p></form>")

Response.Write("<div id=""like"" style=""width: 500px; height: 300px""></div>")


'Close all objects, data objects and all so no connection is left open 

objDataReader.Close()

objDataReader = Nothing

objCommand.Dispose()

objCommand = Nothing

objConnect.Close()

objConnect = Nothing

End Sub

 

</script>

 <% Page_Load %>

</body> 
</html>
Thanks
Shan
 
The problem I see is that you are using classic ASP style of coding. With ASP.NET, you should use the code behind model and not mix code with HTML. Since you say you are new to .net, then I would suggest getting an intro book or use one of the many on-line resources like
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top