473,396 Members | 1,726 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,396 software developers and data experts.

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:HyperLink 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.Page
{
protected System.Web.UI.WebControls.HyperLink MyHLink;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
//this.MyHLink.NavigateUrl = MyString();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.Load += new System.EventHandler(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(object sender, System.EventArgs e)
{
MyHLink.NavigateUrl = 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 4171
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.NavigateUrl = 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**************@TK2MSFTNGP11.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:HyperLink 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.Page
{
protected System.Web.UI.WebControls.HyperLink MyHLink;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
//this.MyHLink.NavigateUrl = MyString();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.Load += new System.EventHandler(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(object sender, System.EventArgs e)
{
MyHLink.NavigateUrl = 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.NavigateUrl = 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***************@TK2MSFTNGP14.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
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....
1
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,...
0
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...
2
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...
4
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"...
1
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...
1
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...
7
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...
1
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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.