how to create pop up window with hyperlink in asp - asp.net

I am trying to create a popup window when clicked the hyperlink. Currently, my hyperlink is opening the entire page which is huge and i would like to make like a pop up, smaller size. How can i do that?
Here is my code:
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("ID", "~/DET/Policy.Merket?ID={0}") %>' Target="_blank">POLICY</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
i come back just to post the solution in case someone needs:
`<asp:Hyperlink Runat="server" NavigateUrl='<%# Eval("ID", "~/DET/Policy.Merket?ID={0}") %>' onclick="window.open (this.href, 'popupwindow', 'width=400,height=400,scrollbars,resizable'); return false;">Link text goes here<asp:Hyperlink>`

You could use the javascript window.open() function in a pure HTML button. Copying from here, you can see an example defining the popup window size etc.
Link text
Another alternative would be to use jQuery and specifically the overlay tool.
Hope I helped!

use the ajaxtoolkit modalpopup
it will much more helpfull for you
thanks,

Related

Get Image from database by clicking on link button in gridview in asp .Net

I have LinkButton in grid view
<asp:TemplateField HeaderText="Images">
<ItemTemplate>
<asp:LinkButton ID="lnkDrvImgLic" CommandArgument='<%# Eval("intVou") %>' CommandName="viewLicImg" runat="server">Licence Image</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<%#Eval("intVou") %> is Primary key and it should show the image from database based on primary key. Does it requires any parameter for server path?
It would be fine if I can open image in new tab.
Or you can instead use the Hyperlink control like this:
<asp:HyperLink NavigateUrl='<%# String.Concat("~/",Eval("ImagePathField")) %>' Target="_blank" runat="server" >L</asp:HyperLink>
Notice that you must use "~/" to get the relative path for the image. Also you need to add Target"_blank" to open the image in new tab.
Hope this helps.

How to remove postback on linkbutton inside gridview?

I'd like to ask on how to prevent post back when a LinkButton inside the GridView is clicked?
My current implementation is that, I have a GridView with customer details and the button link which is the ID link button, once this link button is clicked the customer details will be shown on their respective fields (i.e. textbox, etc), but I want it to look like more interactive and faster when clicking the said button by removing Post back. How can I achieve this? Thanks.
So just to confirm my answer after our comments, replace this...
<asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="linkView" CssClass="View" Text ='<%# Eval("ID")%>' runat="server"></asp:LinkButton> </ItemTemplate> </asp:TemplateField>
...with this...
<asp:TemplateField> <ItemTemplate> <%# Eval("ID")%> </ItemTemplate> </asp:TemplateField>
...where loadViaAjax is a Javascript function which populates your customer fields via AJAX or some other means. Ensure this function returns false to prevent the browser responding to the anchor click.
Please mark this as the answer if it works for you.

Calendar control is not popping-up when clicked on image

I'm using a CalendarExtender control with the help of <img> to populate a TextBox with a date. I am using this in EditItemTemplate of GridView. But when I click on the image, the calendar control is not poping up.
I have used this CalendarExtender control in four or five other places (in this project) also. Everywhere else it is working fine. I have compared the code from the well working version to this code. No difference at all.
I have written the code like below:
<EditItemTemplate>
<asp:TextBox ID="txtDateDelivered" runat="server"
Text='<%# Bind("DateDelivered","{0:dd/MM/yy}") %>'
CssClass="DateTextBoxInGridView" >
</asp:TextBox>
<asp:CalendarExtender ID="calexDateDelivered" runat="server"
Format="dd/MM/yy"
TargetControlID="txtDateDelivered"
PopupButtonID="calDateDelivered">
</asp:CalendarExtender>
<img src="Images/calendar.gif"
id="calDateDelivered"
alt="Calendar" />
</EditItemTemplate>
Can anybody please tell where could be the problem?
how many row do you have in grid? also probably you have more than one image with such id
The image tag which you have used is not a server control.
It is simple html control, this is the reason why the calender control does not reconise this image control..
Try using asp.net image button over here instead of .
It should work then.
cheers....
Rahul C.

Eval property and extra text on a button's text property

I'm using an asp Button like follows:
<asp:Button id="someButton" runat="Server" Text='<%# Eval("Size") %>' />
This is great but before the Eval Property result I wanted to add the Text "Download " with possibly the units after it.
eg. Download 123KB.
Can someone please tell me how to go about this?
In this case it might be easier to set the text property of the button on the server in the page load event.
insted of button use linkButton.
**asp:LinkButton ID="HyperLink2" OnClick="HyperlinkSelectedCustomers_Click" runat="server" CommandArgument='<%#Eval("id") %>' ><%#Eval("selectedCustomers") %>/asp:LinkButton

How can I make a DISPLAYED DATA(int) in a PARTICULAR COLUMN to be a hyperlink in a GRIDVIEW?

How can I make a DISPLAYED DATA(int) of a PARTICULAR COLUMN to be a hyperlink in a GRIDVIEW, so when I click on that DATA it will display details of that chosen row line items.
This video does something similiar to that. The details are not inline, but the concept is kind of what you're looking for. There is a grid view, and when clicking on an item, the details view below is populated with the row details. This may give you some ideas. Hope this helps.
http://www.asp.net/learn/3.5-videos/video-363.aspx
I assume that you will give your details at another page, here is a hyperlink column that points to a details page :
<asp:HyperLinkColumn
HeaderText="Show Details"
DataNavigateUrlField="YourIntegerColumn"
DataNavigateUrlFormatString="detailspage.aspx?id={0}" />
Though I don't think it is what you want, you might want to display details inside of hover text. This should work for you.
<asp:TemplateField HeaderText="Id">
<ItemTemplate><asp:Label ID="LabelId" runat="server" Text='<%# Eval("Id") %>' ToolTip='<%# Eval("Details") %>' /></ItemTemplate>
</asp:TemplateField>

Resources