473,668 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I call a function from a hyperlink in C# ?

Could anyone please tell me how I can call a function from a hyperlink
in C# ?

Examples of scenarios where this would be useful include :-

Loop through a set of records in a repeater and have a hyperlink to
edit each record by passing it's record id to another page.

Loop through a set of files on a server and have a hyperlink to
download a file via a stream on another page by passing its filename
(this is so that the full path of the file is not revealed to the
user).

ie

I have a function within "Codebehind " (which works fine).

public void DownloadFile( string fname,bool forceDownload)
{
.......
.......
.......
}

I have tried calling the function from the ASP page in various ways
such as :-

<asp:HyperLin k NavigateUrl="<% #DownloadFile(" test.doc",true) %>">Download
file</asp:HyperLink>

This method results in the error "The best overloaded method match for
'System.Convert .ToString(objec t)' has some invalid arguments"

I have tried various permutations of single quotes, double quotes etc.

I also considered using <asp:LinkButton > but this only seems to allow
one parameter to be passed to the function.

Surely there must be an very simple solution to this in .Net as it was
extremely easy to do in Classic ASP.

If anyone could propose a solution to this problem I would be very
grateful indeed.

Regards
John
Jul 21 '05 #1
1 11480
Try using a LinkButton.
-mike
MVP

"Fresh Air Rider" <Fr************ *@Hotmail.com> wrote in message
news:55******** *************** ***@posting.goo gle.com...
Could anyone please tell me how I can call a function from a hyperlink
in C# ?

Examples of scenarios where this would be useful include :-

Loop through a set of records in a repeater and have a hyperlink to
edit each record by passing it's record id to another page.

Loop through a set of files on a server and have a hyperlink to
download a file via a stream on another page by passing its filename
(this is so that the full path of the file is not revealed to the
user).

ie

I have a function within "Codebehind " (which works fine).

public void DownloadFile( string fname,bool forceDownload)
{
......
......
......
}

I have tried calling the function from the ASP page in various ways
such as :-

<asp:HyperLin k NavigateUrl="<% #DownloadFile(" test.doc",true) %>">Download
file</asp:HyperLink>

This method results in the error "The best overloaded method match for
'System.Convert .ToString(objec t)' has some invalid arguments"

I have tried various permutations of single quotes, double quotes etc.

I also considered using <asp:LinkButton > but this only seems to allow
one parameter to be passed to the function.

Surely there must be an very simple solution to this in .Net as it was
extremely easy to do in Classic ASP.

If anyone could propose a solution to this problem I would be very
grateful indeed.

Regards
John

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
23826
by: sumGirl | last post by:
Is it possible to use a hyperlink to call a vbs sub? I have seen folks using javascript to do this, but I cannot make it work with vbs and I need to. Please no "you should use javascript" answers. Unfortunately I am where I am and I have to use vbs.
6
13289
by: NB | last post by:
Hi Is there any way to call up the query design view from code? In my compiled-as-MDE app everything is hidden from end users. However, I want advanced user to have access to the query design view so they can create, run and export their own query. Another question is: can they be prevented from saving those on-the-fly queries?
5
2967
by: Rob | last post by:
Help me, I'm just beginning with programming in Access 2000. I've tried the http://www.mvps.org/access/api/api0001.htm but it won't work in Access. What am i doing wrong. I don't have problems with the http://www.mvps.org/access/api/api0002.htm but it only browse to folders.
5
4505
by: Fresh Air Rider | last post by:
Could anyone please tell me how I can call a function from a hyperlink in C# ? Examples of scenarios where this would be useful include :- Loop through a set of records in a repeater and have a hyperlink to edit each record by passing it's record id to another page. Loop through a set of files on a server and have a hyperlink to download a file via a stream on another page by passing its filename
1
1855
by: D. Shane Fowlkes | last post by:
Hello All. I keep asking for help with this on the www.asp.net forums and nobody seems to be able to help. What I'm trying to accomplish is very simple. I simply want to create a Hyperlink Column in a Datagrid and reformat the text output of the column. The helper function seems to be working but the hyperlink column isn't properly being render into html. The actual hyperlink web control is showing up in the html when tested on two...
1
603
by: Fresh Air Rider | last post by:
Could anyone please tell me how I can call a function from a hyperlink in C# ? Examples of scenarios where this would be useful include :- Loop through a set of records in a repeater and have a hyperlink to edit each record by passing it's record id to another page. Loop through a set of files on a server and have a hyperlink to download a file via a stream on another page by passing its filename
2
4991
by: SAL | last post by:
I would like to create a VB.net function, that builds a dynamic hyperlink using System.Web.UI.WebControls.HyperLink, but I can not find any examples on how to generate a dynamic hyperlink. Has anyone done this before? I do not want to dynamically create my hyperlink on an ASP page, but rather a behind the scenes link that a user can paste into a Word document or Email, as an embedded link that points to a particular file. This would be...
2
5568
by: Antonio | last post by:
Hi, I would like to have my TreeNode to call window.close(); without posting back, how can I do that? At the same time, I prefer to have a SelectAction property that allows my TreeNode to appear as hyperlink with hand-cursor when hover. For your information, my TreeView control is on a master page. I have done some tricks but when clicking the node, it does the post-back and my page appears empty with nothing on it except the popup...
2
2798
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0. Herein lies the problem; if the order number is 0, I do not want the grid to display anything. If...
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8374
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.