Link to home
Create AccountLog in
Avatar of Member_2_5230414
Member_2_5230414

asked on

Passing vb.net data via ajax/javascript

url: "Default2.aspx?name="+name+"&time="+now+"&post="+post,

how would i set name if im using this on the front pafge
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

You want to set the variable "name"?

var name = "runnerjp2005";
url: "Default2.aspx?name="+name+"&time="+now+"&post="+post,

Open in new window

It's not clear what you're trying to accomplish here.  Do you want to dynamically modify a link so the parameter "name" changes based on something else?
Avatar of Member_2_5230414
Member_2_5230414

ASKER

var name = "runnerjp2005";
url: "Default2.aspx?name="+name+"&time="+now+"&post="+post,

Open in new window



i would like to use my textbox.text value and add it to the url so i can call it from my next page

var name = textboxvalue

the issue is this code id on the front page (seen below)

<%@ page language="VB" autoeventwireup="false" codefile="Profiles.aspx.vb" inherits="members_Profiles" %>
<!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 id="Head1" runat="server">
<title></title>
<link href="../Styles/Site.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="../Javascript/imagecycle.js"></script>
<script type="text/javascript" src="../Javascript/curvycorners.js"></script>
<script type="text/javascript" src="../Javascript/JScript.js"></script>
<script type="text/javascript" >
    $(function () {
        $(".submit").live("click", function () {

            var comment = $("#textbox").val();
            var dataString = '&comment=' + comment;
            if (comment == '') {
                alert('Please Give Valid Details');
            }
            else {
                $("#flash").show();
                $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" />Loading Comment...');
                $.ajax({
                    type: "POST",
                    url: "Default2.aspx?name=" + name + "&time=" + now + "&post=" + post, 
                    data: dataString,
                    cache: false,
                    success: function (html) {
                        $("div#update").append(html);
                        $("div#update li:last").fadeIn("slow");
                        $("#flash").hide();
                    }
                });
            } return false;
        });
    });


    </script>
    
</head>
<body>
<form id="form1" runat="server">
 <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

	<div id="top-page-header">
		<div id="head-wrapper">
			<div id="site-logo">
				<asp:image id="Image1" runat="server" imageurl="~/images/runningprofilestext.gif"/>
				<asp:image id="Image2" runat="server" imageurl="~/images/rplogo.gif"/>
			</div>
		</div>
	</div>
	<div class ="largeMain">
		<div id="leftarea">
			<div id="profileimage">
				<div id="profileimageround" runat="server">
							</div>
			</div>
			<div id="profileinfopanel">
				<center>
				<h3><asp:label id="Name" runat="server" text="Label"></asp:label> Info </h3>
				</center> Name: Jarratt Perkins <br/><br/> Sex: Male<br/><br/> Age: 23<br/><br/> Club: Notts AC<br/><br/>
				<asp:imagebutton id="ImageButton1" runat="server" imageurl="~/images/maleicon.JPG"/> Send User a Message <br/>
				<asp:imagebutton id="ImageButton2" runat="server" imageurl="~/images/Adduser.JPG"/> Add User
			</div>
			<div id="friends">
				My Friends will go here
			</div>
		</div>
		<div id="rightarea">
			<div id="usersblog">
				<div id="leftblog">
					<script type="text/javascript">
					    if (iens6) {
					        document.write('<div id="container" style="margin-left:10px;float:left;position:relative;width:567px;height:220px;border:1px solid black;overflow:hidden">')
					        document.write('<div id="content" style="margin-left:10px;float:left;position:absolute;width:567px;left:0;top:0">')
					    }
                 </script>
					<div id="nscontainer">
						<div id="nscontent">
							<asp:label id="thetext" runat="server" text="Label"></asp:label>
						</div>
					</div>
					<script type="text/javascript">
					    if (iens6) {
					        document.write('</div></div>')
					    }
					    function button_onclick() {

					    }

                    </script>
					<div style="float:left; height: 216px;">
						<a href="#" onmouseover="moveup()" onmouseout="clearTimeout(moveupvar)"><img alt="up" src="../images/uparrow.png" border="0"/></a><br/>
						<div style="margin-top:165px">
							<a href="#" onmouseover="movedown()" onmouseout="clearTimeout(movedownvar)"><img alt="down" src="../images/downarrow.png" border="0"/></a>
						</div>
					</div>
				</div>
				<div id="rightblog">
					<div id="pblabel">
						<asp:imagebutton id="PBbutton" imageurl="~/images/pbbtn.png" runat="server"/>
					</div>
					<div id="bloglabel">
						<asp:imagebutton id="Blogbutton" imageurl="~/images/blogbtn.png" runat="server"/>
					</div>
					<div id="traininglabel">
						<asp:imagebutton id="Tlogbutton" imageurl="~/images/trainingbtn.png" runat="server"/>
					</div>
				</div>
			</div>
           
			<div id="profilenewsfeed"><div id="shoutinput" >
               
               
                       <asp:TextBox name="textbox" id="textbox" TextMode="MultiLine" runat="server"></asp:TextBox>
								<div id="button-box">
                                    <asp:Button Text="Submit" CssClass="submit" type="submit" id="Submit" value="Submit" runat="server" />
                                    <asp:Button Text="Close" class="button" type="submit" id="close" value="Cancel" runat="server" />
                                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
           <div align="left" id="character-count">
<div id="count">140</div> 
</div>

 </div> 
								</div>
                          <div id="flash"></div>     
                                <div id="update" class="timeline">                               
                                  
</div>
 <li class="box">
 <div class="shoutbox">
 
       
                                <div class="shoutbox-image"> <asp:Image ID="Image4" runat="server" ImageUrl="~/images/50profiles.jpg" /></div>
                                <div class="shoutbox-other">fuehu rufhuie hreuhv euihreuh trueiurehur ehureht urehuthruthruihtuirhtuirhtuirhtur hurhuriehg iruhruiehgfruei rueghruehurrg grrgrgreg</div> 
                                <div class="shoutbox-reply">&nbsp;<asp:Button ID="Reply" runat="server" Text="Reply" Visible="true" /><asp:Button ID="closebox" runat="server" Text="Close" Visible="false" />
                                     </div>
                                    
                                         <asp:TextBox ID="Replytextbox" Visible="false" runat="server" Width="439px" 
                                    CssClass="Replytextbox"></asp:TextBox>
                              
                            </div>
</li>






			</div>

                        
          
           </div>


		</div>

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

Open in new window

You can use:
var name = document.getElementById("textNameHere").value;

Open in new window

I think [Medo3337]'s solution is perfect.
ok i used it here

   $("#flash").show();
                $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" />Loading Comment...');
                $.ajax({
                    type: "POST",
                    var post= document.getElementById("textbox").value;
                    url: "Default2.aspx?post=" + post, 
                    data: dataString,
                    cache: false,
                    success: function (html) {
                        $("div#update").append(html);
                        $("div#update li:last").fadeIn("slow");
                        $("#flash").hide();
                    }
                });
            } return false;

Open in new window



but for   var post= document.getElementById("textbox").value; i get the error expecting identifiyer or string
What textbox does "Name" come from?
ASKER CERTIFIED SOLUTION
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account