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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing querystring parameter to server-side code

Status
Not open for further replies.

browski99

Programmer
Sep 20, 2002
2
GB
I've been trying to resolve this problem for a couple of days and have given up so here goes........

I have a page in vb.net that displays a record, there is a button which is used to delete the record. When the user clicks the button a confirmation message pops up with OK/Cancel to carry out the deletion, if they select OK another confirmation message pops up with OK/Cancel to archive the record. If they select Ok the record is deleted and a file is created on their local drive.

The confirmations are written in Javascript and a parameter is added to a url depending on whether they want to delete and/or archive.

I want to use the parameter in my code-behind to determine whether to delete and/or archive but I cannot see the query string parameter in the code-behind when I do a Request.Querystring, only the id for the record is shown.

When I do an alert fromn javascript for the xmlHttp.responseText te uerystring parameter is their

Any help would be greatly appreciated


below is the javascript code:-
<script type="text/javascript">

function confirmation() {
var answer = confirm("Do you want to delete this record?")

if (answer==true)
{
var ans = confirm("Do yo want to archive this record?")
if(ans)
{
delete_record("Archive");
}
else
{
delete_record("No Archive");
}
}
}

// create HttpRequest Object
function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

function delete_record(archive){

var addr = "DeletePractice.aspx?archive=" + archive

//create the http request object
xmlHttp=GetXmlHttpObject()
xmlHttp.onreadystatechange=stateChanged

xmlHttp.open("POST",addr, true);
xmlHttp.setRequestHeader("Content-type", "application/x- xmlHttp.setRequestHeader("Content-length", addr.length);
xmlHttp.setRequestHeader("Connection", "close")

xmlHttp.send(addr)
}

function stateChanged(){
if (xmlHttp.readyState==4 || xmlHttp.readyState==200){
alert(xmlHttp.responseText);
window.reload();
}
}

</script>

Many thanks
 
You aren't passing the params in properly (I don't think). Try changing your definition for the addr variable to not include any of the GET params you currently have... and modifiy the send method to pass in the GET params there:
Code:
...
  var addr = "DeletePractice.aspx";
...
  xmlHttp.send("archive=" + archive);
...

Let us know how you go!

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top