java script code.
<script type="text/javascript">
function ajaxFunction()
{
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function()
{
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('results');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var fname = document.getElementById('txtfname').value;
var lname = document.getElementById('txtlname').value;
var addr = document.getElementById('addr').value;
var queryString = "?fname=" + fname + "&lname=" + lname + "&addr=" + addr;
ajaxRequest.open("GET", "process.aspx" + queryString, true); // give the
query string here
ajaxRequest.send(null);
}
</script>
call this function on button click as follows
<table class="style1">
<tr>
<td>
First Name</td>
<td>
<asp:TextBox ID="txtfname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Last Name</td>
<td>
<asp:TextBox ID="txtlname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Address</td>
<td>
<asp:TextBox ID="txtAddr" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Button ID="Button1" runat="server" Text="Ok"
OnClientClick="ajaxFunction();"/>
<asp:Button ID="Button2" runat="server" Text="Reset" />
</td>
</tr>
</table>
then in process.aspx page in page load event check the query string
& insert the values.
the above code may have syntax errors please let me know if any .
I am posting this code without compilation
Thanks & Regards,
Shrinivas Mada,
cell : 9975638418
On Thu, May 14, 2009 at 11:19 AM, Jeena Ajiesh <[email protected]> wrote:
> Can u pls tell me with some sample data how to use Ajax for this?
>
> Thank U
>
> On Wed, May 13, 2009 at 12:57 PM, shrinivas mada <[email protected]>wrote:
>
>>
>> hey u can try by ajax.
>> u can send values from one page to other page asynchronously
>>
>> Thanks & Regards,
>> Shrinivas Mada,
>>
>>
>>
>>
>>
>> On Wed, May 13, 2009 at 1:37 PM, Jeena Ajiesh <[email protected]> wrote:
>>
>>> Hi all,
>>> Can anyone help me in passing some values from database to another page.
>>> I dont want the user to redirect to that page.But stay in the current
>>> page and pass the values only.
>>> I need to send like
>>> ...(
>>> http://www.mysite.com/sendvalues.php?uid=name&pwd=pass&to=valuefromdb&txt=againvaluefromdb
>>> )
>>> What should i give? whether Reponse.Redirect or Server.Send....
>>>
>>> i tried out like
>>> Server.Send(http://www.mysite.com/sendvalues.php?uid=jee&pwd=jee&to="&
>>> num &" "&txt="&
>>> againvaluefromdb<http://www.mysite.com/sendvalues.php?uid=jee&pwd=jee&to=%22&+num+&%22+%22&txt=%22&+againvaluefromdb>
>>> )
>>>
>>> But i cant get the actual result.Some error as it is expecting virtual
>>> path
>>>
>>> Please help me if anyone knows abt this
>>>
>>> Thanks In Advance.
>>> jeena
>>>
>>>
>>>
>>
>
>
> --
> ****************
> Thanks & Regards,
> Jeena Ajiesh
> Email: [email protected]
> [email protected]
>
> Sent from Dubayy, United Arab Emirates
>