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

ASCX - Function Not Being Called

I created a simple user control which contains a hyperlink to link the user
to a topic in a compiled help file. I named all my help topics to have the
same name as the aspx they are for.

So in the user control help.ascx's html, I have this:
<a href='<%# GenerateHelpLink()%>' class="mischrefcontent2" id="hrfHelp"
runat="server" target="_blank">Help</a>

In the codebehind help.ascx.cs, I have this:
#region GenerateHelpLink
protected void GenerateHelpLink()
{
StringBuilder sb = new StringBuilder();
sb.Append("ms-its:");

sb.Append(ConfigurationSettings.AppSettings["ApplicationURL"].ToString());
sb.Append(ConfigurationSettings.AppSettings["HelpFile"].ToString());
string[] arScript =
Request.ServerVariables["SCRIPT_NAME"].ToString().Split("/".ToCharArray());
string sScript = arScript[arScript.GetUpperBound(0)].ToString();
sb.Append(sScript.Substring(0, sScript.LastIndexOf(".")));
sb.Append(".htm");

// you can ignore these details - this function simply returns a help
URL

return sb.ToString();
}
#endregion

So if I'm at cs_completed.aspx, the above function will return:
ms-its:http://gdurzi/framework/help/MyFelpF..._completed.htm

In cs_completed.aspx, I do this:
<%@ Register TagPrefix="framework" TagName="help" Src="ascx\help.ascx" %>
and
<framework:help id="_help" runat="server"></framework:help>

The text Help (what's inside the <a></a>) is displayed, but the hyperlink
doesn't work. Upon debugging, I realized the function GenerateHelpLink is
never being called ...

I want to accomplish this without having to write code into every page to
call this function. I just wanted to plop the user control in there and let
it do it's work.. Any idea?
Nov 17 '05 #1
4 3491
Instead of using an <a> tag, I would use a Hyperlink control.

Then in page_load do something like:

Hyperlink1.NavigationURL = GenerateHelp();

"George Durzi" <gdurzi@nospam_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I created a simple user control which contains a hyperlink to link the user to a topic in a compiled help file. I named all my help topics to have the
same name as the aspx they are for.

So in the user control help.ascx's html, I have this:
<a href='<%# GenerateHelpLink()%>' class="mischrefcontent2" id="hrfHelp"
runat="server" target="_blank">Help</a>

In the codebehind help.ascx.cs, I have this:
#region GenerateHelpLink
protected void GenerateHelpLink()
{
StringBuilder sb = new StringBuilder();
sb.Append("ms-its:");

sb.Append(ConfigurationSettings.AppSettings["ApplicationURL"].ToString());
sb.Append(ConfigurationSettings.AppSettings["HelpFile"].ToString());
string[] arScript =
Request.ServerVariables["SCRIPT_NAME"].ToString().Split("/".ToCharArray()); string sScript = arScript[arScript.GetUpperBound(0)].ToString();
sb.Append(sScript.Substring(0, sScript.LastIndexOf(".")));
sb.Append(".htm");

// you can ignore these details - this function simply returns a help
URL

return sb.ToString();
}
#endregion

So if I'm at cs_completed.aspx, the above function will return:
ms-its:http://gdurzi/framework/help/MyFelpF..._completed.htm

In cs_completed.aspx, I do this:
<%@ Register TagPrefix="framework" TagName="help" Src="ascx\help.ascx" %>
and
<framework:help id="_help" runat="server"></framework:help>

The text Help (what's inside the <a></a>) is displayed, but the hyperlink
doesn't work. Upon debugging, I realized the function GenerateHelpLink is
never being called ...

I want to accomplish this without having to write code into every page to
call this function. I just wanted to plop the user control in there and let it do it's work.. Any idea?

Nov 17 '05 #2
I would have to put code in the Page_Load of every ASPX page in my
application. I am trying to avoid that.

Any idea why the GenerateHelpLink() function doesn't get called though? It
doesn't make a diff if I use an <a> or a <asp:hyperlink>

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:ex*************@TK2MSFTNGP11.phx.gbl...
Instead of using an <a> tag, I would use a Hyperlink control.

Then in page_load do something like:

Hyperlink1.NavigationURL = GenerateHelp();

"George Durzi" <gdurzi@nospam_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I created a simple user control which contains a hyperlink to link the

user
to a topic in a compiled help file. I named all my help topics to have the same name as the aspx they are for.

So in the user control help.ascx's html, I have this:
<a href='<%# GenerateHelpLink()%>' class="mischrefcontent2" id="hrfHelp"
runat="server" target="_blank">Help</a>

In the codebehind help.ascx.cs, I have this:
#region GenerateHelpLink
protected void GenerateHelpLink()
{
StringBuilder sb = new StringBuilder();
sb.Append("ms-its:");

sb.Append(ConfigurationSettings.AppSettings["ApplicationURL"].ToString()); sb.Append(ConfigurationSettings.AppSettings["HelpFile"].ToString());
string[] arScript =

Request.ServerVariables["SCRIPT_NAME"].ToString().Split("/".ToCharArray());
string sScript = arScript[arScript.GetUpperBound(0)].ToString();
sb.Append(sScript.Substring(0, sScript.LastIndexOf(".")));
sb.Append(".htm");

// you can ignore these details - this function simply returns a help URL

return sb.ToString();
}
#endregion

So if I'm at cs_completed.aspx, the above function will return:
ms-its:http://gdurzi/framework/help/MyFelpF..._completed.htm

In cs_completed.aspx, I do this:
<%@ Register TagPrefix="framework" TagName="help" Src="ascx\help.ascx" %> and
<framework:help id="_help" runat="server"></framework:help>

The text Help (what's inside the <a></a>) is displayed, but the hyperlink doesn't work. Upon debugging, I realized the function GenerateHelpLink is never being called ...

I want to accomplish this without having to write code into every page to call this function. I just wanted to plop the user control in there and

let
it do it's work.. Any idea?


Nov 17 '05 #3
No, you would need to put this code into Page_Load of the user control, not
the page.

I don't think the <%# %> tags work that way if it's not part of databinding
code. If you did something like <% Response.Write(GenerateHelp()); %> that
would probably do it.

But this is doing it the old fashioned ASP way. I think putting all this
type of code into Page_Load is a much neater way to do it. It follows the
idea of separating UI and code that ASP.NET introduces.

"George Durzi" <gdurzi@nospam_hotmail.com> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
I would have to put code in the Page_Load of every ASPX page in my
application. I am trying to avoid that.

Any idea why the GenerateHelpLink() function doesn't get called though? It
doesn't make a diff if I use an <a> or a <asp:hyperlink>

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:ex*************@TK2MSFTNGP11.phx.gbl...
Instead of using an <a> tag, I would use a Hyperlink control.

Then in page_load do something like:

Hyperlink1.NavigationURL = GenerateHelp();

"George Durzi" <gdurzi@nospam_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I created a simple user control which contains a hyperlink to link the

user
to a topic in a compiled help file. I named all my help topics to have the same name as the aspx they are for.

So in the user control help.ascx's html, I have this:
<a href='<%# GenerateHelpLink()%>' class="mischrefcontent2" id="hrfHelp" runat="server" target="_blank">Help</a>

In the codebehind help.ascx.cs, I have this:
#region GenerateHelpLink
protected void GenerateHelpLink()
{
StringBuilder sb = new StringBuilder();
sb.Append("ms-its:");

sb.Append(ConfigurationSettings.AppSettings["ApplicationURL"].ToString()); sb.Append(ConfigurationSettings.AppSettings["HelpFile"].ToString()); string[] arScript =

Request.ServerVariables["SCRIPT_NAME"].ToString().Split("/".ToCharArray());
string sScript = arScript[arScript.GetUpperBound(0)].ToString();
sb.Append(sScript.Substring(0, sScript.LastIndexOf(".")));
sb.Append(".htm");

// you can ignore these details - this function simply returns a help URL

return sb.ToString();
}
#endregion

So if I'm at cs_completed.aspx, the above function will return:
ms-its:http://gdurzi/framework/help/MyFelpF..._completed.htm

In cs_completed.aspx, I do this:
<%@ Register TagPrefix="framework" TagName="help" Src="ascx\help.ascx" %> and
<framework:help id="_help" runat="server"></framework:help>

The text Help (what's inside the <a></a>) is displayed, but the hyperlink doesn't work. Upon debugging, I realized the function GenerateHelpLink is never being called ...

I want to accomplish this without having to write code into every page to call this function. I just wanted to plop the user control in there
and let
it do it's work.. Any idea?



Nov 17 '05 #4
Thank you, that worked. For some reason I thought the Page_Load event of the
user control wouldn't fire.

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
No, you would need to put this code into Page_Load of the user control, not the page.

I don't think the <%# %> tags work that way if it's not part of databinding code. If you did something like <% Response.Write(GenerateHelp()); %> that
would probably do it.

But this is doing it the old fashioned ASP way. I think putting all this
type of code into Page_Load is a much neater way to do it. It follows the
idea of separating UI and code that ASP.NET introduces.

"George Durzi" <gdurzi@nospam_hotmail.com> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
I would have to put code in the Page_Load of every ASPX page in my
application. I am trying to avoid that.

Any idea why the GenerateHelpLink() function doesn't get called though? It
doesn't make a diff if I use an <a> or a <asp:hyperlink>

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:ex*************@TK2MSFTNGP11.phx.gbl...
Instead of using an <a> tag, I would use a Hyperlink control.

Then in page_load do something like:

Hyperlink1.NavigationURL = GenerateHelp();

"George Durzi" <gdurzi@nospam_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
> I created a simple user control which contains a hyperlink to link the user
> to a topic in a compiled help file. I named all my help topics to have
the
> same name as the aspx they are for.
>
> So in the user control help.ascx's html, I have this:
> <a href='<%# GenerateHelpLink()%>' class="mischrefcontent2" id="hrfHelp" > runat="server" target="_blank">Help</a>
>
> In the codebehind help.ascx.cs, I have this:
> #region GenerateHelpLink
> protected void GenerateHelpLink()
> {
> StringBuilder sb = new StringBuilder();
> sb.Append("ms-its:");
>
>

sb.Append(ConfigurationSettings.AppSettings["ApplicationURL"].ToString()); >

sb.Append(ConfigurationSettings.AppSettings["HelpFile"].ToString()); > string[] arScript =
>

Request.ServerVariables["SCRIPT_NAME"].ToString().Split("/".ToCharArray());
> string sScript = arScript[arScript.GetUpperBound(0)].ToString();
> sb.Append(sScript.Substring(0, sScript.LastIndexOf(".")));
> sb.Append(".htm");
>
> // you can ignore these details - this function simply returns a

help
> URL
>
> return sb.ToString();
> }
> #endregion
>
> So if I'm at cs_completed.aspx, the above function will return:
> ms-its:http://gdurzi/framework/help/MyFelpF..._completed.htm >
> In cs_completed.aspx, I do this:
> <%@ Register TagPrefix="framework" TagName="help"
Src="ascx\help.ascx" %>
> and
> <framework:help id="_help" runat="server"></framework:help>
>
> The text Help (what's inside the <a></a>) is displayed, but the

hyperlink
> doesn't work. Upon debugging, I realized the function
GenerateHelpLink is
> never being called ...
>
> I want to accomplish this without having to write code into every
page to
> call this function. I just wanted to plop the user control in there

and let
> it do it's work.. Any idea?
>
>



Nov 17 '05 #5

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

Similar topics

0
by: Lily | last post by:
Hi all, Any help is greatly appreciated. I have two ascx called MyFirstAscx.ascx and MySecondAscx.ascx. These two are contained in MyPage.aspx I have a function in MySecondAscx.ascx called...
0
by: dh | last post by:
As a simple example, I can't seem to be able to reference a label called "lblOutput" that exists in my test.aspx page from within a User control, TestControl.ascx. I am stumped. Any help is...
1
by: Quentin | last post by:
hey there, ok i made a class, that inherits webcontrol, and i add an htmltable to it. I was wondering how to declare an ascx file as an object in my class, like that i could change the content...
4
by: Rob Meade | last post by:
Hi all, I have just put together our organisations 'template' for our web applications and have created 7 .ascx files which when dropped into my template file work perfectly...however, I have a...
1
by: Andrew Parsons | last post by:
Hi all, I had a weird issue with trying to use a cookie in a ASCX housed on my web forms and I was wondering if I am missing something. I wanted to use the authenticated cookie for the user...
3
by: runtoofar | last post by:
I have an ASCX user control with a drop down list inside an ASPX (C#) page. The user selects an item from the DDL, clicks a button, and the DDL.SelectedValue is supposed to be sent to another...
6
by: Martin Eyles | last post by:
Hi, I have a .aspx page which has a .ascx file included through the lines <%@ Register TagPrefix="aspcustom" TagName="menu" Src="Menu.ascx" %> and <aspcustom:menu id="Menu1"...
2
by: Peter Kirk | last post by:
Hi I have an ascx (MainCalendarControl.ascx), which includes another ascx, by using this statement at the top of MainCalendarControl.ascx: Register TagPrefix="CalendarUI"...
3
by: Steven Nagy | last post by:
Hi all, ASP.NET : Framework 2.0 - C# A recent addition to my code generater will create GridView's and ObjectDataSource's in a control (ASCX). So the code gen creates an ascx, ascx.cs,...
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
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
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...
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...
0
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...
0
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...

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.