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

Adding parameter to the url from a UserControl

Hi,

How do one add parameters to a URL from a UserControl?

My problem is that I want to set a unique value to the webpage when the
page loads. This value I will use as a identifier for that session
(user). I'm certain it's a simple solution for this. But I have not been
able to locate it yet.

Usually in the old days, I would just generate input hidden tags in the
form tag to hold this data...

I would appreciate greatly for any pointers on this issue.

- Kjell Arne

Nov 15 '05 #1
4 1863
Hi,

I really do not understand what you are trying to do, but anyway this is
what you can do.
You can declare a "hidden" control in several ways, if you are going to use
it only in the server side then any ASP.NET control with the Visible
property to false will not show in the page and it will accesible in the
server side.
if you are planning in using it in the client as well then you can use the
HtmlInputHidden control in the same way that you use other control.

Now a tip that I do not why is not more know, you can declare ANY control in
the HTML as accessable from the server side, all you have to do is put in
the tag runat="server" and then in the page you can declare that control as
of type HtmlGenericControl . One example, let's say that you want to set the
page's title dinamically, this is what you do:
in the HTML page instead of:
<title>listrecords</title>
you use:
<title runat="server" id="pagetag">listrecords</title>

then in the code behind you declare the control as:
protected System.Web.UI.HtmlControls.HtmlGenericControl pagetag;

and set it like :
pagetag.InnerText = "Set from code";
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Kjell Arne" <sa****@atc.no_yiha|spam> wrote in message
news:3f********@news.broadpark.no...
Hi,

How do one add parameters to a URL from a UserControl?

My problem is that I want to set a unique value to the webpage when the
page loads. This value I will use as a identifier for that session
(user). I'm certain it's a simple solution for this. But I have not been
able to locate it yet.

Usually in the old days, I would just generate input hidden tags in the
form tag to hold this data...

I would appreciate greatly for any pointers on this issue.

- Kjell Arne

Nov 15 '05 #2
Hi.

Well, my problem is that I am working on a webpage where I do not have
access to anything but my own UserControl project.

When the webpage loads, I want to write a unique identifier string that
will be placed somewhere(?!) in the webpage, so I can retrieve it when
the user sends post data to the server. That way I can register that id
in the database and make sure that he does not register again with that
session key.

I've been told that I might be able to add parametres to the url in the
browser?! (I cannot see how that is possible though, but I'm new to C# so..)
- Kjell Arne

Hi,

I really do not understand what you are trying to do, but anyway this is
what you can do.
You can declare a "hidden" control in several ways, if you are going to use
it only in the server side then any ASP.NET control with the Visible
property to false will not show in the page and it will accesible in the
server side.
if you are planning in using it in the client as well then you can use the
HtmlInputHidden control in the same way that you use other control.

Now a tip that I do not why is not more know, you can declare ANY control in
the HTML as accessable from the server side, all you have to do is put in
the tag runat="server" and then in the page you can declare that control as
of type HtmlGenericControl . One example, let's say that you want to set the
page's title dinamically, this is what you do:
in the HTML page instead of:
<title>listrecords</title>
you use:
<title runat="server" id="pagetag">listrecords</title>

then in the code behind you declare the control as:
protected System.Web.UI.HtmlControls.HtmlGenericControl pagetag;

and set it like :
pagetag.InnerText = "Set from code";
Hope this help,


Nov 15 '05 #3
Hi again,

So in other words you are programming the control and you do not control
when/where this control will be used, right?
If that is so, then I think that you do not need to put a string in the page
you can generate this id when the cnotrol is build the first time, then it
will be kept using the state. you can make this property public if you need
so.
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Kjell Arne" <sa****@atc.no_yiha|spam> wrote in message
news:3f********@news.broadpark.no...
Hi.

Well, my problem is that I am working on a webpage where I do not have
access to anything but my own UserControl project.

When the webpage loads, I want to write a unique identifier string that
will be placed somewhere(?!) in the webpage, so I can retrieve it when
the user sends post data to the server. That way I can register that id
in the database and make sure that he does not register again with that
session key.

I've been told that I might be able to add parametres to the url in the
browser?! (I cannot see how that is possible though, but I'm new to C# so..)

- Kjell Arne

Hi,

I really do not understand what you are trying to do, but anyway this is what you can do.
You can declare a "hidden" control in several ways, if you are going to use it only in the server side then any ASP.NET control with the Visible
property to false will not show in the page and it will accesible in the
server side.
if you are planning in using it in the client as well then you can use the HtmlInputHidden control in the same way that you use other control.

Now a tip that I do not why is not more know, you can declare ANY control in the HTML as accessable from the server side, all you have to do is put in the tag runat="server" and then in the page you can declare that control as of type HtmlGenericControl . One example, let's say that you want to set the page's title dinamically, this is what you do:
in the HTML page instead of:
<title>listrecords</title>
you use:
<title runat="server" id="pagetag">listrecords</title>

then in the code behind you declare the control as:
protected System.Web.UI.HtmlControls.HtmlGenericControl pagetag;

and set it like :
pagetag.InnerText = "Set from code";
Hope this help,

Nov 15 '05 #4
Hi..

And thanks you for your help. Do you think you can give me an example of
doing this? I do not understand what you mean with "You can generate
this id and it will be kept using the state".

So how do I generate this id? And what is a state? Are you refering to
VIEWSTATE?

- Kjell Arne
Hi again,

So in other words you are programming the control and you do not control
when/where this control will be used, right?
If that is so, then I think that you do not need to put a string in the page
you can generate this id when the cnotrol is build the first time, then it
will be kept using the state. you can make this property public if you need
so.
Hope this help,


Nov 15 '05 #5

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

Similar topics

3
by: Dunc | last post by:
I'm writing an app that uses a lot of time-date functions, so I'm trying to create a calendar-type user control that adds a day, month, and year box to a number of places on my page. I can...
2
by: Chien Lau | last post by:
I frequently define internal UserControl-derived classes in my WinForms apps: internal class MyUserControl:UserControl{ ... } I'll often need to embed these controls in a Form, whose class...
7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
1
by: elziko | last post by:
I have sucessfully created a control that inherits from a UserControl. Now I want to extend this by adding extra controls but if I try and drop a control onto the form then I just get the "No"...
5
by: amatuer | last post by:
hi i have a link from page1 to page2. this link uses a querystring to transfer data. usually i have no problems using querystring t transfer data. bt for the first time page2 does not display.an...
1
by: bonk | last post by:
I have a very simple UserControl (derived from System.Windows.Forms.UserControl) that contains several ListViews. The UserControl exposes a single public property: public...
3
by: Jeff | last post by:
Hey ASP.NET 2.0 This the ObjectDataSource in my UserControl, <asp:ObjectDataSource ID="odsMessage" runat="server" SelectMethod="ExecuteMessage" TypeName="AH.MyNetwork.BLL.Network.Message">...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
1
by: jrobbins | last post by:
<asp:ObjectDataSource ID="statusDataSource" runat="server" TypeName="datamanager" SelectMethod="GetReferenceData"> <SelectParameters> <asp:Parameter Name="Level" Type="int32" DefaultValue='0'/>...
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:
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
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
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...
0
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...

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.