Mindcracker MVP Summit 2012
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » ASP.NET & Web Development » Link word to google search
       
Author Reply
sam
posted 69 posts
since Jul 04, 2010 
from

Link word to google search

  Posted on: 02 Sep 2010       
Hi.I have a code here where it will capture value from textbox and add in a temporary gridview (not sent to database).
My question is,when a value from textbox is added in the gridview,how to make that value in gridview as a link where it can search the value in google.

Any ideas guys?

[code]
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Style="z-index: 106;
    left: 322px; position: absolute; top: 301px">
    <Columns>
    <asp:TemplateField HeaderText="Call Information">
    <ItemTemplate>
    <asp:Label ID="LblName" runat="server" Text='<%#Eval("name")%>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateField>

   
    
    <asp:TemplateField HeaderText="">
    <ItemTemplate>
    <asp:Button ID="BtnDelete" runat="server" Text="Clear" OnClick="BtnDelete_Click" />
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
[/code]
sam
Manikavelu Velayutham
posted  682 posts
since  Jun 25, 2010 
from 

 Re: Link word to google search
  Posted on: 02 Sep 2010        0  

Its so simple. If you type something in google.com, for example I typed "textbox" in google and clicked search. You can see the link in addressbar like http://www.google.co.in/search?hl=en&source=hp&q=textbox&aq=f&aqi=g2g-s1g1g-s1g1g-s4&aql=&oq=&gs_rfai=
so just concatenate the textbox.text in the above link, so that it will directly search the google wiht the appropriate text.
 
dont forget to mark this post as answered or mark it as good post.
If you find my post helpful, Mark it as Answered or Rate the post.
sam
posted  69 posts
since  Jul 04, 2010 
from 

 Re: Link word to google search
  Posted on: 02 Sep 2010        0  
Hi Mani,
where do i apply/modify the code?
sam
Manikavelu Velayutham
posted  682 posts
since  Jun 25, 2010 
from 

 Re: Link word to google search
  Posted on: 02 Sep 2010        0  

Just put a hyperlink button in the gridview, and whenver you add the value from the text box to the grid. Just do it as below
string str = "http://www.google.co.in/search?hl=en&source=hp&q=XXXX&aq=f&aqi=g2g-s1g1g-s1g1g-s4&aql=&oq=&gs_rfai=";
str.replace("XXXX",textbox1.text);
finally store this string in the URL property of hyperlink button of the gridview.
First try with the label itself, if its doesnt work, put the hyperlink button and test it.
Surely it should work
dont forget to mark this post as answered or mark it as good post.
If you find my post helpful, Mark it as Answered or Rate the post.
sam
posted  69 posts
since  Jul 04, 2010 
from 

 Re: Link word to google search
  Posted on: 02 Sep 2010        0  
Hi Mani..so sorry,i m new to this asp.net..

I have a code here :
[code]
<head runat="server">
    <title>Untitled Page</title>
    <script runat="server">
    protected void AddPersonButton_Click(object sender, EventArgs e)
        {
            ArrayList peoplearraylist = new ArrayList();
            if (ViewState["people"] != null)
            {
                peoplearraylist = (ArrayList)ViewState["people"];
            }
            else
            {
                peoplearraylist = new ArrayList();
            }
            string firstname = FirstNameTextBox.Text;
            string lastname = LastNameTextBox.Text;

            Person addperson = new Person(firstname, lastname);
            peoplearraylist.Add(addperson);
            ViewState["people"] = peoplearraylist;
            FirstNameTextBox.Text = "";
            LastNameTextBox.Text = "";
            DisplayListOfPeople();
        }

        protected void DisplayListOfPeople()
        {
            ShowPeople.Text = "";
            ArrayList peoplearraylist = new ArrayList();
            if (ViewState["people"] != null)
            {
                peoplearraylist = (ArrayList)ViewState["people"];
                foreach (Person currentperson in peoplearraylist)
                {
                    ShowPeople.Text += currentperson.Firstname + " " + currentperson.Lastname + "<br />";
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     First Name: <asp:TextBox ID="FirstNameTextBox" runat="server"></asp:TextBox><br /><br />
        Last Name: <asp:TextBox ID="LastNameTextBox" runat="server"></asp:TextBox><br /><br />
        <asp:Button ID="AddPersonButton" runat="server" Text="Add"
            onclick="AddPersonButton_Click" />       
           
       
       
        <br /><br />
       
        <asp:Label ID="ShowPeople" runat="server" />

    </div>
    </form>
</body>
[/code]

when i enter value in the textbox,it will temporarily display the value at the bottom.
lets say i enter company 1 in first textbox,company 1 will be displayed as a label at bottom.
i want the name company 1 word is linked to google search when when we click the company 1,it will automatically display google search results as company 1.
sam
sam
posted  69 posts
since  Jul 04, 2010 
from 

 Re: Link word to google search
  Posted on: 02 Sep 2010        0  
I got it (for my first code post)

<ItemTemplate>
<a href='http://www.google.com/#q=<%# Eval("name")%>'>
<%#Eval("name")%></a>
</ItemTemplate>


But now i have an iframe and want the page redirected to this iframe.
Any ideas?

My iframe code :
<iframe runat="server" id="iframe1" src=""
style="height: 300px; width: 635px" frameborder="0"></iframe>


sam
       
Mindcracker MVP Summit 2012
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Discover the top 5 tips for understanding .NET Interop
Ricky Leeks presents the top 5 tips for understanding .NET Interoperability. Learn more.
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
Discover the top 5 tips for understanding .NET Interop
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved