473,657 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hyperlink and dynamically formed NavigateURL problem

Hello !

This post does'nt regard column hyperlink.
I just have single hyperlink and want to create it's NavigateUrl
dynamically.

This is my test page

<form id="Form1" method="post" runat="server">
<asp:HyperLin k id="MyHLink" NavigateUrl='<% # geturl("123456" ) %>'
style="Z-INDEX: 101; LEFT: 280px; POSITION: absolute; TOP: 56px"
runat="server" >MyHLink</asp:HyperLink>
</form>

and my class behind

public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Hype rLink MyHLink;
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
//this.MyHLink.Na vigateUrl = MyString();
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
protected string geturl(string s)
{ return "www.mypage .com "+s; }
}

Resulting page includes hyperlink, but inactive - not href tag attached. The
syntax is O'K, I believe (no errors on page load).
I've spent a couple of hours for browsing the newsgroups but haven't find
working solution for HTML designing.
What means, I can do this but only when setting NavigateUrl in Page_Load
like this:

private void Page_Load(objec t sender, System.EventArg s e)
{
MyHLink.Navigat eUrl = geturl("123456" );
}

No matter what kind of Url I put (absolute, relative) - Page_Load works
every time.

The only reason I can think about, is that one: geturl and class-behind is
not accessible, when hyperlink is rendered based on design values.
Am I right ?
If yes, how about datagrid and TemplateItem column with hyperlink. In that
case settings like above work perfectly. What is the differences between
datagrid column and hyperlink on page ?

Regards,

--
Tomek R.
Nov 19 '05 #1
4 4215
instead of doing NavigateUrl='<% # geturl("12345") %>' do NavigateUrl='<% =
getUrl("12345") %>'

<%# is for databinding, you aren'd databinding and therefore need touse <%=

doing it form your Page_Load, ala:
MyHLink.Navigat eUrl = geturl("123456" );

should work (And is how you should do it, no clumsy method calls in your
presentation), but if you still had the <%# in there, dunno how that would
behave...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Tomek R." <to********@wp. pl> wrote in message
news:Op******** ******@TK2MSFTN GP11.phx.gbl...
Hello !

This post does'nt regard column hyperlink.
I just have single hyperlink and want to create it's NavigateUrl
dynamically.

This is my test page

<form id="Form1" method="post" runat="server">
<asp:HyperLin k id="MyHLink" NavigateUrl='<% # geturl("123456" ) %>'
style="Z-INDEX: 101; LEFT: 280px; POSITION: absolute; TOP: 56px"
runat="server" >MyHLink</asp:HyperLink>
</form>

and my class behind

public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Hype rLink MyHLink;
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
//this.MyHLink.Na vigateUrl = MyString();
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
protected string geturl(string s)
{ return "www.mypage .com "+s; }
}

Resulting page includes hyperlink, but inactive - not href tag attached. The syntax is O'K, I believe (no errors on page load).
I've spent a couple of hours for browsing the newsgroups but haven't find
working solution for HTML designing.
What means, I can do this but only when setting NavigateUrl in Page_Load
like this:

private void Page_Load(objec t sender, System.EventArg s e)
{
MyHLink.Navigat eUrl = geturl("123456" );
}

No matter what kind of Url I put (absolute, relative) - Page_Load works
every time.

The only reason I can think about, is that one: geturl and class-behind is
not accessible, when hyperlink is rendered based on design values.
Am I right ?
If yes, how about datagrid and TemplateItem column with hyperlink. In that
case settings like above work perfectly. What is the differences between
datagrid column and hyperlink on page ?

Regards,

--
Tomek R.

Nov 19 '05 #2
Karl !
Thanks for reply.
<%# is for databinding, you aren'd databinding and therefore need touse

<%=
Yeah, I found some posts with this info, but <%= doesn't work. The resulting
link is the whole phrase, inlcuding <% .

--
Tomek R.
Nov 19 '05 #3
Ya, was being an idiot when I just woke up :)

The correct way to go, as I originally said, is via the Page_Load and doing
MyHLink.Navigat eUrl = geturl("123456" );

if you are certain Page_Load is running, and you don' thave NavigateUrl set
to anything in the HTML (don't even specifiy the problem), it should work.

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Tomek R." <to********@wp. pl> wrote in message
news:%2******** *******@TK2MSFT NGP14.phx.gbl.. .
Karl !
Thanks for reply.
<%# is for databinding, you aren'd databinding and therefore need touse <%=
Yeah, I found some posts with this info, but <%= doesn't work. The

resulting link is the whole phrase, inlcuding <% .

--
Tomek R.

Nov 19 '05 #4
Karl !

Thanks for reply.

--
Tomek R.
Nov 19 '05 #5

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

Similar topics

4
8948
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
1
6949
by: Mark | last post by:
Ok this is very odd. I have a hyperlink server control (not a linkbutton) on my .aspx page. When the navigateurl property is set to a file (blah.aspx) in the same directory as the current page, the page posts back BEFORE redirecting to the next page. If I change the navigateurl property to go to a page in a subfolder (foo\bar.aspx) it does not do a postback. I swear I'm not messing with it - I did the experiment 3 times in a row ......
0
550
by: Ryan Harvey | last post by:
Hi all, I have written a web user control that contains a repeater control. the ItemTemplate for this control is basically 6 Hyperlinks in a row, that are dynamically allocated one of 7 gif images as the ImageURL of the Hyperlink. When a load the page with the controls on it works fine, but sometimes the images are broken, but if i hit refresh i get random selections of the gifs appearing and not appearing. if i hit Back button to a page...
2
6761
by: Robson Carvalho Machado | last post by:
Dear friends, I'm dynamically creating a Hyperlink with spacer.gif as ImageURL that is an 1px transparent image only to determine link position, but as I create this link dynamically I could not set image width. This problem makes my link clickable only on its borders. When viewing HTML source I could see that spacer.gif has no width and height, so HTML shows only 1px x 1 px image.
4
2212
by: Satya | last post by:
Hi all, The following code is throwing a run time error "The server tag is not well formed. " <ItemTemplate> <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl="javascript:OpenImage('<%# DataBinder.Eval(Container.DataItem,"FileName") %>');"><%#
1
1487
by: Elmo Watson | last post by:
Ok - I've got a datalist - in the template, there is a hyperlink, in which, I need to dynamically use the record's ID inside a Javascript function (a popup window function, which works perfectly with implicit ID) The problem I think, is where to put the single and double quotes - I get a The server tag is not well formed error. Here's the last one that didn't work: <asp:Hyperlink id="hyLink"
1
3530
by: ashtek | last post by:
Hi, I am using a hyperlink on a datagrid (templatecolumn) to display a link. Onclick of this link I want to open a new window without tool bar & with certain width & height. I am using this code <ASP:TEMPLATECOLUMN HEADERTEXT="Details"> <ITEMTEMPLATE> <ASP:HYPERLINK ID="lnkDetails" RUNAT="server" NAVIGATEURL='<%# "Details.aspx?ID=" + DataBinder.Eval(Container.DataItem,"ID")%>'
7
7043
by: ashtek | last post by:
I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to open a new window with no toolbar and specific height & width onclick of the link. I also want to pass the PK to this new window. <ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#" ONCLICK="javascript:window.open('NewWin.aspx?PK=<%# DataBinder.Eval(Container.DataItem,"PK")%>','','toolbar=0,width=600,height=600,scollbars=1')" TEXT="Click"></ASP:HYPERLINK> ...
1
1800
by: mister-Ed | last post by:
I am displaying subcategories in my datalist, and now I have a bizarre thing happen when I add a new subcategory record in my sql database, the new subcategory link does not click into the next page. When clicking the link, nothing happens!: code to link w/querystrings formatted: <a href="prov-results1.aspx?county=< %#Server.UrlEncode(Request.QueryString("county")) & "&subcat=" & Server.UrlEncode((Eval("SubCategory").ToString())) &...
0
8394
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
8732
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
8605
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
7327
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
6164
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...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
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.