Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I have a textBox in the index page and I want it to take the value from this text to the google search engine in another page.
 
how can i pass this variable from control to the cse?
 
This is the index code for passing the variable
 
Response.Redirect("Search.aspx?parma=" + TextBox1.Text);
 
and this is cse code
 
<script>
            (function () {
                var cx = '003646811200027851123:9ubv0q_x_z0';
                var gcse = document.createElement('script');
                gcse.type = 'text/javascript';
                gcse.async = true;
                gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
                var s = document.getElementsByTagName('script')[0];
                s.parentNode.insertBefore(gcse, s);
            })();
        </script>
        <gcse:search></gcse:search>
Posted 28-Mar-13 7:33am
Nuha IT654
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello,
 
Please find below the code to do this.
<!DOCTYPE html>
<html>
<head>
<title>Element V2: Google-hosted Layout Demo</title>
 
<!-- Put the following javascript before the closing </head> tag. -->
<script>
  (function() {
    var cx = '003646811200027851123:9ubv0q_x_z0';
    var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
  })();
</script>
</head>
 
<body>
<div>
  Element V2 Google-hosted Layout Demo: open the results page in a new window
</div>
 
<!-- Place this tag where you want the search box to render -->
<!--
  1) newWindow=true overwrites settings stored in CSE control panel.
  2) Or store your settings in CSE control panel "Look and Feel" tab:
     Choose where your Google-hosted results appear: "New Window" or
     "Current Window".
 -->
<gcse:searchbox-only newWindow=true></gcse:searchbox-only>
</body>
 
</html>
Regards,
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

All I needed is this attribute
 
<gcse:search queryparametername="q" xmlns:gcse="#unknown"></gcse:search>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 280
1 Jochen Arndt 150
2 Kornfeld Eliyahu Peter 120
3 PIEBALDconsult 110
4 Richard MacCutchan 105
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100