473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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:hyperlink 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 2309
not with the webcontrol controls, as asp.net assumes these are postback
events

-- bruce (sqlwork.com)

"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message
news:uT**************@tk2msftngp13.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:hyperlink 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 HtmlServerControls 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/
vbconchoosingwebformscontrols.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?frame=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.microsoft.com> wrote in message
news:Wo**************@cpmsftngxa06.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
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:...
2
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...
4
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....
4
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...
5
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...
2
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...
9
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,...
1
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...
2
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.