Category Archives: HyperLink

[RESOLVED] How to write code for download a file..

Hello,

I have web page, in that I place some links(hyperlinks or linkbuttons).

each button, when user clicks then a file should be downloaded to the user system..

files that are to be downloaded exists in asp.net website project folder>>downloads folder..

can any one give code for the above requirement.

Many Thanks,

Gouse Baig.

[RESOLVED] datagrid popout with window limits

hi all

I have a datagrid I want the popout window limited ti a certine size with on bars or anything.  I know there is a javescript that works with webcontrols but what do you do in this situation with this type

 

<asp:DataGrid id="MyList" BorderColor="black" GridLines="Vertical" cellpadding="4" cellspacing="0" ShowFooter="true" AutoGenerateColumns="false" runat="server">
    <FooterStyle font-size="Smaller" BackColor="#C0C0FF" font-names="Arial" forecolor="Black"></FooterStyle>
    <HeaderStyle font-size="Smaller" BackColor="#C0C0FF" font-names="Arial" forecolor="Black"></HeaderStyle>
    <ItemStyle font-size="Smaller" BackColor="White" font-names="Arial" forecolor="Black"></ItemStyle>
	<Columns>
        <asp:BoundColumn HeaderText="Contact ID" DataField="ID" />
        <asp:BoundColumn HeaderText="First Name" DataField="first_name" />
        <asp:BoundColumn HeaderText="Last Name" DataField="last_name" />
        <asp:BoundColumn HeaderText="E-mail" DataField="email_address"></asp:BoundColumn>
        <asp:HyperLinkColumn HeaderText="Contact Details" Text="Contact Details" DataNavigateUrlField="ID" DataNavigateUrlFormatString="contact_details.aspx?ContactID={0}"  Target="_blank" />
    </Columns>
    </asp:DataGrid>


 

Well after a little bit I seemed to figure it out

 

<script type="text/javascript">
    function movepic(img_name, img_src) {
        document[img_name].src = img_src;
    }
    function SetTarget() {


        document.forms[0].target = "_blank";


    }
    var URLPOS = 0, NAMEPOS = 1, PROPERTYPOS = 2;


    function OpenWin(props) {
        var lsProperties, myWin, lsURLPrefix;


        if (props.split)
            lsProperties = props.split("|");
        else
            lsProperties = OldBrowserSplit(props, "|");


        if (lsProperties[URLPOS] != null) {
            if (lsProperties[NAMEPOS] == null)
                lsProperties[NAMEPOS] = "";


            if (lsProperties[PROPERTYPOS] == null)
                lsProperties[PROPERTYPOS] = "";




            lsURLPrefix = ""


            if (lsProperties[URLPOS].substring(0, 4) != "http") {


                if (lsProperties[URLPOS].substring(0, 1) != "/")


                    lsURLPrefix = "";




            }


            myWin = window.open(lsURLPrefix + lsProperties[URLPOS], lsProperties[NAMEPOS], lsProperties[PROPERTYPOS]);




        }


    }


    function OldBrowserSplit(OrigStr, tok) {
        var it = new Array();
        var counter = 0, cur = 0, prev = 0;
        var str = OrigStr;


        cur = str.indexOf(tok, prev);
        while (cur != -1) {
            it[counter] = str.substring(prev, cur);
            counter += 1;
            str = str.substring(cur + 1);
            prev = 0;
            cur = str.indexOf(tok);
        }
        it[counter] = str.substring(prev);
        return it;
    }
</script>


<asp:HyperLinkColumn HeaderText="Contact Details" Text="Contact Details" DataNavigateUrlField="ID" DataNavigateUrlFormatString="javascript:OpenWin('contact_details.aspx?ContactID={0}||height=250,width=300,location=no,resizable=no,scrollbars=no,toolbar=no');"/>


 

[RESOLVED] HTML Encoding in an asp:LinkButton

Hey All

I am trying to use HTML Encoding in an asp:LinkButton, but it is not working for me. Here is my code:

<% foreach (var id in item.DataID)
	 { %>
		<asp:LinkButton runat="server" ID="DailyUnitValueHyperLink"
					Text="Daily Trends"
					onclick="DailyUnitValueHyperLink_Click"
					CommandArgument="<%: id %>"></asp:LinkButton>
   <% } %>


I am getting the DataId from list of string on my page Model. I am then trying to place that ID into the CommandArgument of the LinkButton. But it is not working.

I have tried both of these and neither work:

I don't think a code block like this can work.   You're trying to create multiple LinkButtons, all with the same ID, and ID's are required to be unique.

I suggest using a Repeater to handle this.

http://www.w3schools.com/ASPNET/aspnet_repeater.asp 

[RESOLVED] How to remove red border around the image when using "HyperLink" control

hi there,

I have few images on my aspx website and was trying to do a simple link to another page from the image.  Noticed that the image control does not let me specify the url, and when i was playing wtih <a href... in source code i run into some issues.

Then i noticed HyperLink control and i used that one.  In a property window i see "ImageURL", and "NavigateURL", so i guess that eliminated the need for a "Image" control. 

The only problem that i run into with the "hyperlink" control is that once the link is created, the image has a "nasty" red border which i need to remove but i am not sure how to.  I set border style to None and it did not work.  Then i tried to set border width to 0 and still i have a red border around my image. 

How do i remove that annoying red border and is there a better way to do image link with aspx?

thanks,
X. 

i'd use css

try adding this to your stylesheet

    a img {border-style:none;}

 

Mike,

I don't use stylesheets, but when i use border-style:none in the property window of the control i still have the red border.  

 

 

you dont want to apply the style to the Hyperlink control as you be applying the style to the anchor tag rather than to the image that inside the anchor tag.

I'd encourage you to consider using stylesheets. 

you can also add a little inline style on your page just to see how it works.

<style type="text/css">

    a img {border-style:none;}

</style>

 

Mike,

Thank you for your advice and suggestion, it solved my problem.

Cheers,
X.