473,664 Members | 2,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP:HyperLink control and client-side scripting

Hi All,

I know this is a dumb question, but I'll ask it anyway...

How do you do client-side scripting with an ASP control?

For example I have:

<asp:hyperlin k id="Hyperlink1 " runat="server" NavigateUrl="~/"
onclick="return false;">Home</asp:hyperlink>

When I run this it works as expected, except the IDE sees it as and error.

I know I can add the attribute in the codebehind, but is this possible in
the HTML designer side?

TIA
Brian W
Nov 18 '05 #1
4 2320
not with the webcontrol controls, as asp.net assumes these are postback
events

-- bruce (sqlwork.com)

"Brian W" <brianw@gold_de ath_2_spam_rush .com> wrote in message
news:uT******** ******@tk2msftn gp13.phx.gbl...
Hi All,

I know this is a dumb question, but I'll ask it anyway...

How do you do client-side scripting with an ASP control?

For example I have:

<asp:hyperlin k id="Hyperlink1 " runat="server" NavigateUrl="~/"
onclick="return false;">Home</asp:hyperlink>

When I run this it works as expected, except the IDE sees it as and error.

I know I can add the attribute in the codebehind, but is this possible in
the HTML designer side?

TIA
Brian W

Nov 18 '05 #2
Hi Brain,
Thanks for posting in the community!
As for your question that "whether possible to add client side attributes
in the ASP.NET server control's html source(aspx page)", I agree with bruce
that we can only specify the Server control's specified attributes in its
tag such as
<asp:Button.. .> <asp:Label ...> ..
In fact, when the asp.net runtime parsing the aspx page, it'll parse the
asp.net server controls( not html server controls) according to its class
in framework, and these classes has their buildin attributes which are
quite different from html element's attributes( only for serverside code's
controling). The runtime construct a server control's instance via the
attribuets and finally render it out to client via some certain mapping
(from these attributes to the proper html element attributes). So we can't
add clientside used attributes in ASP.NET server control's source template
in aspx page(html view). One way to do this is via their' "Attributes "
collection in code behind as you've mentioned. If you do want to add
clientside attributes in aspx file(html view), I think you can try using
the HtmlServerContr ols instead, because they're directly mapping to html
element. Do you think so?

In addition, here are some tech ariticles on the ASP.NET servercontrols and
html server controls:

#ASP.NET Server Controls Recommendations
http://msdn.microsoft.com/library/de...us/vbcon/html/
vbconchoosingwe bformscontrols. asp

#ASP.NET Server Controls and Browser Capabilities
http://msdn.microsoft.com/library/en...msControlsBrow
serCapabilities .asp?frame=true

#HTML Server Controls
http://msdn.microsoft.com/library/en...SyntaxForHTMLC
ontrols.asp?fra me=true

#The Forgotten Controls: HTML Server Controls
http://msdn.microsoft.com/library/en...gottenControls
.asp?frame=true

Hope these also helpful.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Brain,

Have you had a chance to check out my suggestions in the last reply or have
you got any further ideas on this issue? If you have any further questions,
please feel free to post here.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4
I'm good, Thanks!

BrianW

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:Wo******** ******@cpmsftng xa06.phx.gbl...
Hi Brain,

Have you had a chance to check out my suggestions in the last reply or have you got any further ideas on this issue? If you have any further questions, please feel free to post here.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #5

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

Similar topics

0
1265
by: Kevin Quigley | last post by:
Hi, I have a datalist which has an EditItemTemplate section, within this I have a hyperlink control with which I want to open a new window with some help details. This is the hyperlink code: <asp:HyperLink Runat="server" NavigateUrl="Help.htm"></asp:HyperLink> The problem is that when the link is clicked, nothing happens.
2
7955
by: Doug Stiers | last post by:
I have an asp:hyperlink that I need to have some code fire when the link is clicked. The link is in a datagrid and the link is working properly. I tried using the OnInit event to call the subroutine but that fires when the control is rendered. I need the code to fire only when the users clicks on one of the links in the datagrid. Any help would be appreciated, Doug
4
8949
by: Amir Eshterayeh | last post by:
Dear Friends My asp hyperlink goes to relative address instead of absolute. I like navigate url goes to outsite link like www.asp.net but now, it goes to www.mysite/www.asp.net please help. I create the navigatURL from database dynamically. I see the same question mentioned here but the response is not souitable for me: http://www.dotnet247.com/247reference/msgs/11/57708.aspx
4
4387
by: James P. | last post by:
Hello there, I have an asp hyperlink in a template page. In my user control page - code behind page that uses the template, I'd like to turn this link invisible in certain case. Is it possible? This is my hyperlink: <asp:HyperLink id="hplShoppingCart" runat="server" Font-Size="Larger" Font-Names="Arial" NavigateUrl="../forms/ProductOrder.aspx?fn=c">Shopping Cart</asp:HyperLink>
5
6685
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below but here is the snippet of my asp:hyperlink object; <asp:HyperLink NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(Conta iner.DataItem,"CLIENTREF")%> ID="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,...
2
1492
by: MrMike | last post by:
I am attempting to pass a parameter named "BackURL" into a asp:Hyperlink HTML control as shown below. "BackURL" is actually a variable defined in the page's code-behind. However, my current formatting below causes a "Page cannot be displayed" error, and is invalid. How can I properly reference my BackURL variable in the NavigateURL property of the asp:Hyperlink control? Thanks. <asp:HyperLink runat="server" Text="Update"...
9
28036
by: dana lees | last post by:
Hello, I am using asp:HyperLink in a c# asp.net application to open a new window in the following way: <asp:HyperLink ID="lnkSiteName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.name") %>' NavigateUrl='<%# "site.aspx?id=" + DataBinder.Eval (Container.DataItem,"id").ToString()%>' Target="_blank"> </asp:HyperLink>
1
5646
by: khalid sohail | last post by:
hi everybody i want to pass the window size parameter to <asp:hyperlink> attribute Navige URL Property. tell me how to pass the parameter to it.....actually i want to open the new window on the basis to the user click the data in the column i m passing the Query String also to opening page......i have done that work through the datagrid hyperlink column control but the problem was that i cant pass the Querystring to it so that why i m using...
2
2809
by: BobLaughland | last post by:
Hi There, I need a control on my site that is a hyperlink style control, but it must, 1) Have a property that can hold where the hyperlink is pointing to. (e.g. like the NavigateUrl property in the asp:hyperlink control). 2) Also can call my own method when the user clicks on the link (e.g. like the Click event in the asp:linkbutton control).
1
1135
by: rsandes1 | last post by:
Newbie here, I'm trying to code a asp hyperlink control in C#, that has some literal string text concantenated with a programatic date field that changes as a certain conditions changes within my applciation. The hyperlinks are used to select reports based on report dates that are dynamically changed as the report dates change. So I would like the text in the hyperlink stay the same with the exception of the report date in the...
0
8437
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
8861
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
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...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7375
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...
0
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
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.