Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:TemplateField HeaderText="Title" SortExpression="Title">
               <ItemTemplate>
                   <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Url") %>'
                       Text='<%# Eval("Title") %>'></asp:HyperLink>
               </ItemTemplate>
           </asp:TemplateField


This is the part of the grid view code with url.
It is working with url but I want it to work if somesone clicks on the title, then it will open in a new window holding all the fields of database.
Posted
Updated 22-Nov-10 22:34pm
v3
Comments
Sunasara Imdadhusen 23-Nov-10 3:01am    
Updated for formatting
Sunasara Imdadhusen 23-Nov-10 3:02am    
Will have to open popup window?
Dalek Dave 23-Nov-10 4:34am    
Edited for Grammar and Syntax.

Here a link with examples of how to open a popup using javascript.

http://www.javascript-coder.com/window-popup/javascript-window-open.phtml[^]

It seems to me it would be best to create a javascript function
function openItem(url, p1)
{
   window.open (url +"?param=" + p1, "Item: " + p1);
   return false;
}


And use it somewhat like:
NavigateUrl="javascript:openItem('<%# Eval("Url") %>', '<%#Eval(Param1)%');">


Good luck!
 
Share this answer
 
Comments
Dalek Dave 23-Nov-10 4:34am    
Good Call.
if u want to click the button control use the below function.

onclick="return openpopup(this.id);"

then include the script to top of design page.

<script type="text/javascript" src="../Scripts/saction.js"></script>


then write the function to .js file for below code..


C#
function openpopup(id) {
    window.open("/Application/Transaction.aspx", "List", "scrollbars=no,resizable=no,width=400,height=420");
    return false;
}


it will run properly..
 
Share this answer
 
Just add
Target ="_new"
to Hyperlink
 
Share this answer
 
v2
Target="_new"


Example

VB
<asp:HyperLink id="hyperlink1"
     ImageUrl="images/pict.jpg"
     NavigateUrl="http://www.microsoft.com"
     Text="Microsoft Official Site"
     Target="_new"
     runat="server"/>
 
Share this answer
 
if u want create the new popup window based on Script then use below code.. :laugh:



if u want to click the button control use the below function.

onclick="return openpopup(this.id);"


then include the script to top of design page.

<script type="text/javascript" src="../Scripts/saction.js"></script>



then write the function to .js file for below code..


Collapse
function openpopup(id) {
    window.open("/Application/Transaction.aspx", "List", "scrollbars=no,resizable=no,width=400,height=420");
    return false;
}



if u want Open the new window based on Click Event then use Below Code.:confused:.

VB
<asp:HyperLink id="lnk1"
     NavigateUrl="http://www.google.com"
     Text="www.google.com"
     Target="_new"
     runat="server"/>
 
Share this answer
 
Comments
fjdiewornncalwe 3-Dec-10 8:03am    
Velmahesh... In the future, please just use the "Improve Answer" link on your original answer instead of creating an entirely new one. This answer is much better than your first one as it expands on it very well, btw. Cheers.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900