Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Thursday, March 29, 2012

Pass Listitem between Listboxes

I have two listboxes. The first listbox is prepopulated with the selections
that the user has. The "Value" of the items is NOT the same as the "Text".
The user can select an item (or items) from one listbox and move it to the
other listbox. The code for it is:
Dim x, deleted As Integer
For x = 0 To lboxFrom.Items.Count - 1
If lboxFrom.Items.Item(x - deleted).Selected Then
lboxTo.Items.Add(lboxFrom.Items.Item(x - deleted))
lboxFrom.Items.Remove(lboxFrom.Items.Item(x - deleted))
deleted += 1
End If
Next
I have also tried:
Dim x, deleted As Integer
For x = 0 To lboxFrom.Items.Count - 1
If lboxFrom.Items.Item(x - deleted).Selected Then
Dim newItem As New ListItem()
newItem.Text = lboxFrom.Items.Item(x - deleted).Text
newItem.Value = lboxFrom.Items.Item(x - deleted).Value
lboxTo.Items.Add(newItem)
lboxFrom.Items.Remove(lboxFrom.Items.Item(x - deleted))
deleted += 1
End If
Next
The item that passes to the second listbox should have value of the first
listbox item and also the text of the first listbox item. My problem is tha
t
the value and the text of the item placed in the second listbox end up the
same and equal the text of the item in the first listbox. Why is it doing
this and what can I do to get the value for the item from the first listbox
to pass as the value for the item in the second listbox?
Thanks.Hi,
Your code seems fine. Try debugging it, specifically the second way and
place a breakpoint on

> newItem.Text = lboxFrom.Items.Item(x - deleted).Text
then step into until you see what are the runtime values of
lboxFrom.Items.Item(x - deleted).Text and lboxFrom.Items.Item(x -
deleted).Value
I tested (in C# though) with the following handler of the button click:
protected void b1_Click(object s, EventArgs e)
{
System.Web.UI.WebControls.ListItem li;
int i = 0;
while(i < lboxFrom.Items.Count)
{
if(lboxFrom.Items[i].Selected)
{
li = new System.Web.UI.WebControls.ListItem(
lboxFrom.Items[i].Text, lboxFrom.Items[i].Value);
lboxTo.Items.Add(li);
lboxFrom.Items.RemoveAt(i);
continue;
}
i++;
}
}
and the new items in the "To" ListBox have the text *and* the value of the
ones removed from the "From" ListBox
Hope this helps
Martin
"ScoutLee" <ScoutLee@.discussions.microsoft.com> wrote in message
news:D6DA1B2E-1030-4618-94AE-E43069303EDB@.microsoft.com...
> I have two listboxes. The first listbox is prepopulated with the
selections
> that the user has. The "Value" of the items is NOT the same as the
"Text".
> The user can select an item (or items) from one listbox and move it to the
> other listbox. The code for it is:
> Dim x, deleted As Integer
> For x = 0 To lboxFrom.Items.Count - 1
> If lboxFrom.Items.Item(x - deleted).Selected Then
> lboxTo.Items.Add(lboxFrom.Items.Item(x - deleted))
> lboxFrom.Items.Remove(lboxFrom.Items.Item(x - deleted))
> deleted += 1
> End If
> Next
> I have also tried:
> Dim x, deleted As Integer
> For x = 0 To lboxFrom.Items.Count - 1
> If lboxFrom.Items.Item(x - deleted).Selected Then
> Dim newItem As New ListItem()
> newItem.Text = lboxFrom.Items.Item(x - deleted).Text
> newItem.Value = lboxFrom.Items.Item(x - deleted).Value
> lboxTo.Items.Add(newItem)
> lboxFrom.Items.Remove(lboxFrom.Items.Item(x - deleted))
> deleted += 1
> End If
> Next
> The item that passes to the second listbox should have value of the first
> listbox item and also the text of the first listbox item. My problem is
that
> the value and the text of the item placed in the second listbox end up the
> same and equal the text of the item in the first listbox. Why is it doing
> this and what can I do to get the value for the item from the first
listbox
> to pass as the value for the item in the second listbox?
> Thanks.
>

pass null values

I have a web form that allows a user to do a search, they can select all the
parameters on the web form or only select a few. If the user does not select
a value to search on, how can I pass that to stored procedure and get data
back?
example form:
the user can search on
first name
last name
hire date
termination date
if they only know the first and last name, how can i get data back if the
dates are not entered?see DBNull class
-- bruce (sqlwork.com)
"NuB" <me@.me.com> wrote in message
news:Od3vppMAGHA.2788@.TK2MSFTNGP14.phx.gbl...
>I have a web form that allows a user to do a search, they can select all
>the parameters on the web form or only select a few. If the user does not
>select a value to search on, how can I pass that to stored procedure and
>get data back?
> example form:
> the user can search on
> first name
> last name
> hire date
> termination date
> if they only know the first and last name, how can i get data back if the
> dates are not entered?
>
>

Pass parameters to User Control

Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX
page.

Thanks

BenHi Ben,

Create a public method in the usercontrol and access the same from the aspx
page.

Ex:

Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}

Code in the aspx page.

usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");

HTH
Regards
Ashish M Bhonkiya

"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.

--
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
Sorry for the delay in replying:

I have heard that you can use this method to pass the parameter:

<%@.Register tagprefix="CodeLib" Tagname="usrMain" src="http://pics.10026.com/?src=usrMain.ascx" %
<CodeLib:usrMain bodyData="usrText.ascx" linksPage="NoLinks"
requireSecure="False" runat="server" ID="usrMain"/
But the problem is that I cannot seem to extract the data on the ASCX page

Thanks Ben

"Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:e$%23BiHkJEHA.3944@.tk2msftngp13.phx.gbl...
> For this purpose I used to create properties (in user control). This way
you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In
case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > Hi
> > I am using a User Control which is referenced by an ASPX page.
> > How can I pass a string parameter to the user control, from the base
ASPX
> > page.
> > Thanks
> > Ben
Help! I have an aspx that loads the ascx with parameters in a
placeholder as textboxes. On my postback I can't get the values out
of the textboxes. They are still on the screen so I'm sure they are
there.

I'm having a hard time. I've been told they should just be there.
aspx
ascx
ascxwp

The ascxwp is the user control that holds the textboxes.

I assume someone has figured this out. We have 3 asp programmers and
we are all stumped.

"Shaul Feldman" <sfeldman@.writeme.com> wrote in message news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
> For this purpose I used to create properties (in user control). This way you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > Hi
> > I am using a User Control which is referenced by an ASPX page.
> > How can I pass a string parameter to the user control, from the base ASPX
> > page.
> > Thanks
> > Ben
Implement Properties inside of your UserControl
e.g.

Public Property FirstName() as String
Get
Return txtFirstName.text
End Get
Set (value as String)
txtFirstName.text=value
end set
end property

Then just access the properties
"Lynne K." <ltgaer@.assurity.com> wrote in message
news:7a65e5b4.0405110605.559f0d2d@.posting.google.c om...
> Help! I have an aspx that loads the ascx with parameters in a
> placeholder as textboxes. On my postback I can't get the values out
> of the textboxes. They are still on the screen so I'm sure they are
> there.
> I'm having a hard time. I've been told they should just be there.
> aspx
> ascx
> ascxwp
> The ascxwp is the user control that holds the textboxes.
> I assume someone has figured this out. We have 3 asp programmers and
> we are all stumped.
> "Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
> > For this purpose I used to create properties (in user control). This way
you
> > can also pass parameters from aspx file (html).
> > You can access Session to retrieve values. There're plenty of ways. In
case
> > you need some code, I'll try to post.
> > --
> > With the best wishes,
> > Shaul Feldman
> > "Ben" <Ben@.nospam.com> wrote in message
> > news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > > Hi
> > > > I am using a User Control which is referenced by an ASPX page.
> > > > How can I pass a string parameter to the user control, from the base
ASPX
> > > page.
> > > > Thanks
> > > > Ben
> >

Pass Paramter from Repeater - Can't Figure This Out

Hi,
I have a repeater based on a stored procedure. It pulls the following:
catDesc Image
The user sees the category description (catDesc) , and then clicks on
the image (Image) which is bound to the catID. This catID (@dotnet.itags.org.catID --
an integer) is then to be passed to the next page, sculpture2.aspx for
use in a datagrid with a stored procedure.
I understand how to pass a parameter using response.redirect. I've
done so with a dropdownlist in the past by using OnSelectedIndexChanged
and just using dropdownlist.selecteditem.value as the parameter (an
integer in this case) which I use with response.redirect.
Is there an equivalent techinque for using a repeater?
Here is my code:
<asp:repeater runat="server" ID=repeaterOdd>
<itemtemplate>
<p align="left"><%#DataBinder.Eval(Container.DataItem,
"catDesc") %></p>
<p align="left">
<a href="http://links.10026.com/?link=sculpture2.aspx?catDesc=<%#DataBinder.Eval(Container.DataItem,
"catID")%>"
<img src="http://pics.10026.com/?src=<%# DataBinder.Eval(Container.DataItem, "image") %>"></p>
</itemtemplate>
</asp:repeater>
If I pass this parameter as CatID, then I can't retrieve it using a
querysting, and the whole goal is to use a querystring to pass the
parameter. (e.g int passedValue = Request.Querystring["catID"].
Is there some way to pull the selected value of catID out of the
repeater, put it in some kind of variable, and then run a method to
attach it to a response.redirect?
Is there another way to do this? Using a LinkButton?
Thanks in advance.you can replace the image tag with an asp:HyperLink that way the user can
click on the image and be redirected to a page with your catID accesible
thus:
<asp:HyperLink id="HyperLink1" runat="server" ImageUrl="<%#
DataBinder.Eval(Container.DataItem, "image") %>"
NavigateUrl=secondpage.aspx?caiID=<%#DataBinder.Eval(Container.DataItem,
"catID")%>"></asp:HyperLink>
"Ranginald" <davidwank@.gmail.com> wrote in message
news:1146692474.566945.201390@.y43g2000cwc.googlegroups.com...
> Hi,
> I have a repeater based on a stored procedure. It pulls the following:
> catDesc Image
> The user sees the category description (catDesc) , and then clicks on
> the image (Image) which is bound to the catID. This catID (@.catID --
> an integer) is then to be passed to the next page, sculpture2.aspx for
> use in a datagrid with a stored procedure.
> I understand how to pass a parameter using response.redirect. I've
> done so with a dropdownlist in the past by using OnSelectedIndexChanged
> and just using dropdownlist.selecteditem.value as the parameter (an
> integer in this case) which I use with response.redirect.
> Is there an equivalent techinque for using a repeater?
> Here is my code:
> <asp:repeater runat="server" ID=repeaterOdd>
> <itemtemplate>
> <p align="left"><%#DataBinder.Eval(Container.DataItem,
> "catDesc") %></p>
> <p align="left">
> <a href="http://links.10026.com/?link=sculpture2.aspx?catDesc=<%#DataBinder.Eval(Container.DataItem,
> "catID")%>"
> <img src="http://pics.10026.com/?src=<%# DataBinder.Eval(Container.DataItem, "image") %>"></p>
> </itemtemplate>
> </asp:repeater>
> If I pass this parameter as CatID, then I can't retrieve it using a
> querysting, and the whole goal is to use a querystring to pass the
> parameter. (e.g int passedValue = Request.Querystring["catID"].
> Is there some way to pull the selected value of catID out of the
> repeater, put it in some kind of variable, and then run a method to
> attach it to a response.redirect?
> Is there another way to do this? Using a LinkButton?
> Thanks in advance.
>
Thanks for your response. How would I then pull the value?
Still with respons.querystring?
Thanks again.

Pass Paramter from Repeater - Cant Figure This Out

Hi,

I have a repeater based on a stored procedure. It pulls the following:

catDesc Image

The user sees the category description (catDesc) , and then clicks on
the image (Image) which is bound to the catID. This catID (@dotnet.itags.org.catID --
an integer) is then to be passed to the next page, sculpture2.aspx for
use in a datagrid with a stored procedure.

I understand how to pass a parameter using response.redirect. I've
done so with a dropdownlist in the past by using OnSelectedIndexChanged
and just using dropdownlist.selecteditem.value as the parameter (an
integer in this case) which I use with response.redirect.

Is there an equivalent techinque for using a repeater?

Here is my code:

<asp:repeater runat="server" ID=repeaterOdd>
<itemtemplate>
<p align="left"><%#DataBinder.Eval(Container.DataItem,
"catDesc") %></p>
<p align="left">
<a href="http://links.10026.com/?link=sculpture2.aspx?catDesc=<%#DataBinder.Eval(Container.DataItem,
"catID")%>"
<img src="http://pics.10026.com/?src=<%# DataBinder.Eval(Container.DataItem, "image") %>"></p>
</itemtemplate>
</asp:repeater
If I pass this parameter as CatID, then I can't retrieve it using a
querysting, and the whole goal is to use a querystring to pass the
parameter. (e.g int passedValue = Request.Querystring["catID"].

Is there some way to pull the selected value of catID out of the
repeater, put it in some kind of variable, and then run a method to
attach it to a response.redirect?

Is there another way to do this? Using a LinkButton?

Thanks in advance.you can replace the image tag with an asp:HyperLink that way the user can
click on the image and be redirected to a page with your catID accesible
thus:
<asp:HyperLink id="HyperLink1" runat="server" ImageUrl="<%#
DataBinder.Eval(Container.DataItem, "image") %>"
NavigateUrl=secondpage.aspx?caiID=<%#DataBinder.Eval(Container.DataItem,
"catID")%>"></asp:HyperLink
"Ranginald" <davidwank@.gmail.com> wrote in message
news:1146692474.566945.201390@.y43g2000cwc.googlegr oups.com...
> Hi,
> I have a repeater based on a stored procedure. It pulls the following:
> catDesc Image
> The user sees the category description (catDesc) , and then clicks on
> the image (Image) which is bound to the catID. This catID (@.catID --
> an integer) is then to be passed to the next page, sculpture2.aspx for
> use in a datagrid with a stored procedure.
> I understand how to pass a parameter using response.redirect. I've
> done so with a dropdownlist in the past by using OnSelectedIndexChanged
> and just using dropdownlist.selecteditem.value as the parameter (an
> integer in this case) which I use with response.redirect.
> Is there an equivalent techinque for using a repeater?
> Here is my code:
> <asp:repeater runat="server" ID=repeaterOdd>
> <itemtemplate>
> <p align="left"><%#DataBinder.Eval(Container.DataItem,
> "catDesc") %></p>
> <p align="left">
> <a href="http://links.10026.com/?link=sculpture2.aspx?catDesc=<%#DataBinder.Eval(Container.DataItem,
> "catID")%>"
> <img src="http://pics.10026.com/?src=<%# DataBinder.Eval(Container.DataItem, "image") %>"></p>
> </itemtemplate>
> </asp:repeater>
> If I pass this parameter as CatID, then I can't retrieve it using a
> querysting, and the whole goal is to use a querystring to pass the
> parameter. (e.g int passedValue = Request.Querystring["catID"].
> Is there some way to pull the selected value of catID out of the
> repeater, put it in some kind of variable, and then run a method to
> attach it to a response.redirect?
> Is there another way to do this? Using a LinkButton?
> Thanks in advance.
Thanks for your response. How would I then pull the value?
Still with respons.querystring?

Thanks again.

Pass parameters to User Control

Hi
I am using a User Control which is referenced by an ASPX page.
How can I pass a string parameter to the user control, from the base ASPX
page.
Thanks
BenHi Ben,
Create a public method in the usercontrol and access the same from the aspx
page.
Ex:
Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}
Code in the aspx page.
usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");
HTH
Regards
Ashish M Bhonkiya
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
>
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
>
Sorry for the delay in replying:
I have heard that you can use this method to pass the parameter:
<%@.Register tagprefix="CodeLib" Tagname="usrMain" src="http://pics.10026.com/?src=usrMain.ascx" %>
<CodeLib:usrMain bodyData="usrText.ascx" linksPage="NoLinks"
requireSecure="False" runat="server" ID="usrMain"/>
But the problem is that I cannot seem to extract the data on the ASCX page
Thanks Ben
"Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:e$%23BiHkJEHA.3944@.tk2msftngp13.phx.gbl...
> For this purpose I used to create properties (in user control). This way
you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In
case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
ASPX
>
Implement Properties inside of your UserControl
e.g.
Public Property FirstName() as String
Get
Return txtFirstName.text
End Get
Set (value as String)
txtFirstName.text=value
end set
end property
Then just access the properties
"Lynne K." <ltgaer@.assurity.com> wrote in message
news:7a65e5b4.0405110605.559f0d2d@.posting.google.com...
> Help! I have an aspx that loads the ascx with parameters in a
> placeholder as textboxes. On my postback I can't get the values out
> of the textboxes. They are still on the screen so I'm sure they are
> there.
> I'm having a hard time. I've been told they should just be there.
> aspx
> ascx
> ascxwp
> The ascxwp is the user control that holds the textboxes.
> I assume someone has figured this out. We have 3 asp programmers and
> we are all stumped.
> "Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
you
case
ASPX

Pass parameters to User Control

Hi

I am using a User Control which is referenced by an ASPX page.

How can I pass a string parameter to the user control, from the base ASPX
page.

Thanks

BenHi Ben,

Create a public method in the usercontrol and access the same from the aspx
page.

Ex:

Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}

Code in the aspx page.

usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");

HTH
Regards
Ashish M Bhonkiya

"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.

--
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben

Pass Session Variable Value to Crystal Report?

I've got an aspx page that allows the user to select different options
whenever they want to run a report. On this page, I have added an
additional text box for the user to enter in comments about the report
they are running.

I would like to be able to have the comments that the user has entered
to appear on the report that is generated. I thought that I might be
able to pass this text to the report by using a session variable but I
have had no luck. It doesn't matter if I use a session variable to
accomplish this.

Can someone tell me how I can the user's comments from the web form
appear on the report?

Thanks!I figured out a way to accomplish this. I created a session variable
named UComments and stored the text that the user typed in it. On my
Crystal Report I created a blank formula field named UserComments I
next added the following code to my web form:

Dim oRpt As CrystalDecisions.CrystalReports.Engine.ReportDocum ent
= New CrystalDecisions.CrystalReports.Engine.ReportDocum ent()

'*** TELLING THE PROGRAM WHER THE REPORT IS LOCATED
'*** AND WHAT THE REPORT'S NAME IS. ***
oRpt.Load(Session("ReportLocation") & "Grant.rpt")

'*** CODE TO WRITE USER'S COMMENTS TO THE REPORT. ***
oRpt.DataDefinition.FormulaFields.Item("UserComments").Text = "'"
+ Trim(Session("UComments")) + "'"

CrystalReportViewer1.ReportSource = oRpt

crjunk@.earthlink.net (crjunk) wrote in message news:<e45e90aa.0308061021.788041e6@.posting.google.com>...
> I've got an aspx page that allows the user to select different options
> whenever they want to run a report. On this page, I have added an
> additional text box for the user to enter in comments about the report
> they are running.
> I would like to be able to have the comments that the user has entered
> to appear on the report that is generated. I thought that I might be
> able to pass this text to the report by using a session variable but I
> have had no luck. It doesn't matter if I use a session variable to
> accomplish this.
> Can someone tell me how I can the user's comments from the web form
> appear on the report?
> Thanks!

Pass SQL query to another page safely.

I want to pass an SQL Query from one page to another without the user being able to see it. Can anyone tell me how I can do this?What about putting the query in a session or encrypt it and put it in a hidden text field?
I have done this by treating the SQL (or the parameter parts of it) as a string, writing it to a database, then retrieving it from another page. Its not very elegant I know, but it works just fine if you have a specific unique key to identify your user.

regards

Mike
Two ways I can think of...If you are using response.redirect to move to the next page use session. Otherwise put the query into a page property, server.transfer to the new page, cast the httpcontext as the sending page and access the property. Or try this article on 4guys:

http://aspnet.4guysfromrolla.com/articles/020205-1.aspx
Yeah, I found somthing about the server.urlencode and server.urldecode that the article mentions. I'm not sure whether it will catch everything, but I'll see what happens.

Monday, March 26, 2012

pass the control value from one web form to another form

Hi Experts,

I want to pass the selectedDate value from my calender
form to another web form or a web user control. Could you
please show me how to do this?

Thanks in advance.Tom,

There are a number of choices to do so.

Depending on your needs, you could use Server.Transfer or Response.Redirect
and the query string.

To use the query string

Response.Redirect("pagetwo.aspx?date=" & selectedDate.ToString)

Then on page two:

Dim Date As Date = CType(Request.Querystring.Item("date"), Date)

If you want to use Server.Transfer (Which would be more suited if a number
of variables need to be passed to the second page.) I suggest reading up on
it a bit more. It's fairly easy to do, but can be confusing for the user
because they are moved to page two but their browser's address bar will
still display the first page's url.

If you want some quick code samples I have some in the code library of my
web site: www.aboutfortunate.com. Just use the search box in the code
library area and input: "Server.Transfer".

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"tom" <anonymous@.discussions.microsoft.com> wrote in message
news:00d201c3a947$75660be0$a401280a@.phx.gbl...
> Hi Experts,
> I want to pass the selectedDate value from my calender
> form to another web form or a web user control. Could you
> please show me how to do this?
> Thanks in advance.
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/i...te/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetjunkies.com/tutori...?tutorialid=600

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"tom" <anonymous@.discussions.microsoft.com> wrote in message
news:00d201c3a947$75660be0$a401280a@.phx.gbl...
> Hi Experts,
> I want to pass the selectedDate value from my calender
> form to another web form or a web user control. Could you
> please show me how to do this?
> Thanks in advance.
Hi Steve and S. Justin,

Thank you very much for your responses. I'm sorry that I
didn't explain my problem more clearly on my previous
mail. My problem is a different situation. On my page one
there is textbox and the page two only contains a calendar
control. I need to open page one first and click a button
on page one will open the page two. After user selected a
date from the calendar the page two will close and the
date should be shown on the page one's textbox. I'm
struggling with how to pass value back to page one when
the page one is already opened and update page one's data?

Please help me!
Thanks in advance.

>--Original Message--
>Here's a nice, simple way to pass values from one page to
another:
>(VB.NET code)
>'Add data to the context object before transferring
>Context.Items("myParameter") = x
>Server.Transfer("WebForm2.aspx")
>Then, in WebForm2.aspx:
>'Grab data from the context property
>Dim x as Integer = CType(Context.Items
("myParameter"),Integer)
>Of course there are a number of ways to pass values from
one page to
>another, such as using the querystring, cookies, session,
>context, saving to a temporary table in the database
between each page, etc.
>You'll have to decide which technique is best for your
application.
>Here are several good articles on the subject to help you
decide.

>http://msdn.microsoft.com/msdnmag/i.../04/ASPNETUserS
tate/default.aspx
>http://www.aspalliance.com/kenc/passval.aspx
>http://www.dotnetjunkies.com/tutori...?tutorialid=600
>http://www.dotnetbips.com/displayarticle.aspx?id=79
>--
>I hope this helps,
>Steve C. Orr, MCSD, MVP
>http://Steve.Orr.net
>Hire top-notch developers at http://www.able-
consulting.com
>
>"tom" <anonymous@.discussions.microsoft.com> wrote in
message
>news:00d201c3a947$75660be0$a401280a@.phx.gbl...
>> Hi Experts,
>>
>> I want to pass the selectedDate value from my calender
>> form to another web form or a web user control. Could
you
>> please show me how to do this?
>>
>> Thanks in advance.
>>
>
>.
Tom,

I think this article is just what you need:

http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=614

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"tom" <anonymous@.discussions.microsoft.com> wrote in message
news:0e5401c3a9ee$cd69a7f0$a301280a@.phx.gbl...
> Hi Steve and S. Justin,
> Thank you very much for your responses. I'm sorry that I
> didn't explain my problem more clearly on my previous
> mail. My problem is a different situation. On my page one
> there is textbox and the page two only contains a calendar
> control. I need to open page one first and click a button
> on page one will open the page two. After user selected a
> date from the calendar the page two will close and the
> date should be shown on the page one's textbox. I'm
> struggling with how to pass value back to page one when
> the page one is already opened and update page one's data?
> Please help me!
> Thanks in advance.
> >--Original Message--
> >Here's a nice, simple way to pass values from one page to
> another:
> >(VB.NET code)
> >'Add data to the context object before transferring
> >Context.Items("myParameter") = x
> >Server.Transfer("WebForm2.aspx")
> >Then, in WebForm2.aspx:
> >'Grab data from the context property
> >Dim x as Integer = CType(Context.Items
> ("myParameter"),Integer)
> >Of course there are a number of ways to pass values from
> one page to
> >another, such as using the querystring, cookies, session,
> >context, saving to a temporary table in the database
> between each page, etc.
> >You'll have to decide which technique is best for your
> application.
> >Here are several good articles on the subject to help you
> decide.
> >http://msdn.microsoft.com/msdnmag/i.../04/ASPNETUserS
> tate/default.aspx
> >http://www.aspalliance.com/kenc/passval.aspx
> >http://www.dotnetjunkies.com/tutori...?tutorialid=600
> >http://www.dotnetbips.com/displayarticle.aspx?id=79
> >--
> >I hope this helps,
> >Steve C. Orr, MCSD, MVP
> >http://Steve.Orr.net
> >Hire top-notch developers at http://www.able-
> consulting.com
> >"tom" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:00d201c3a947$75660be0$a401280a@.phx.gbl...
> >> Hi Experts,
> >>
> >> I want to pass the selectedDate value from my calender
> >> form to another web form or a web user control. Could
> you
> >> please show me how to do this?
> >>
> >> Thanks in advance.
> >>
> >.

Pass UserID instead of Username to other pages after logged on, ASP.NET 2.0

Hi,
I have my own user table with definition like
UserID int not null primary key,
Username varchar(50) not null,
Password varchar(50) not null,
Firstname varchar(50) not null,
Lastname varchar(50) not null,
Email varchar(50) not null,
....
I create my own Membership provider to inherit SqlMembershipProvider
public class MyMembershipProvider :
System.Web.Security.SqlMembershipProvider {
public MyMembershipProvider() {
}
public override bool ValidateUser(string username, string password) {
// query my DB to verify user
MyUser mu = new MyUser();
return mu.VerifyUser(username, password);
}
}
In Asp.Net 1.1, we can use
FormsAuthentication.RedirectFromLoginPage(UserID.ToString(), false); to save
UserID (which is whatever I return from my own function, including UserID
from User table). Later on, we just call User.Identity.Name to retrieve the
UserID and it could be used as I like.
But in ASP.NET 2.0, I just need to add
<membership defaultProvider="MyMembershipProvider">
<providers>
<add name="MyMembershipProvider"
type="MyMembershipProvider"/>
</providers>
</membership>
to my web.config file, it will handle authentication autimatically. In this
case how can I pass UserID instead of username to other pages?
Thanks
HardyHardy,
Why pass it around? Why not set a session variable with the information
you need?
- Nicholas Paldino [.NET/C# MVP]
- mvp@.spam.guard.caspershouse.com
"Hardy Wang" <hardywang@.hotmail.com> wrote in message
news:umAPpLP%23FHA.1988@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I have my own user table with definition like
> UserID int not null primary key,
> Username varchar(50) not null,
> Password varchar(50) not null,
> Firstname varchar(50) not null,
> Lastname varchar(50) not null,
> Email varchar(50) not null,
> ....
> I create my own Membership provider to inherit SqlMembershipProvider
> public class MyMembershipProvider :
> System.Web.Security.SqlMembershipProvider {
> public MyMembershipProvider() {
> }
> public override bool ValidateUser(string username, string password) {
> // query my DB to verify user
> MyUser mu = new MyUser();
> return mu.VerifyUser(username, password);
> }
> }
> In Asp.Net 1.1, we can use
> FormsAuthentication.RedirectFromLoginPage(UserID.ToString(), false); to
> save UserID (which is whatever I return from my own function, including
> UserID from User table). Later on, we just call User.Identity.Name to
> retrieve the UserID and it could be used as I like.
> But in ASP.NET 2.0, I just need to add
> <membership defaultProvider="MyMembershipProvider">
> <providers>
> <add name="MyMembershipProvider"
> type="MyMembershipProvider"/>
> </providers>
> </membership>
> to my web.config file, it will handle authentication autimatically. In
> this case how can I pass UserID instead of username to other pages?
>
> Thanks
> Hardy
>

pass value of a variable to user control

Hi,

Trying to pass a value to user control within a page.
1. Couldnt find a way to pass it from code behind file.
2. Trying to pass it from aspx page... using EditURL='<%
"mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
I have tried using a local variable... directly trying to read it off
Request object and even tried using session variable...

could be glad if someone could tell me how to get it right... thanks,

regards,

Hermit DaveYou need to use properties and pass them in the page load events for
example....

Doug Stevens, another MVP has this very useful example whih explains the
approach

http://www.dotnetjunkies.com/Articl...866F720AB013.dc
ik

--
Regards

John Timney (Microsoft ASP.NET MVP)
--------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
--------------

"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:uV5MEnQwDHA.556@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Trying to pass a value to user control within a page.
> 1. Couldnt find a way to pass it from code behind file.
> 2. Trying to pass it from aspx page... using EditURL='<%
> "mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
> I have tried using a local variable... directly trying to read it off
> Request object and even tried using session variable...
> could be glad if someone could tell me how to get it right... thanks,
> regards,
> Hermit Dave
Hello John,

Thanks for the pointer. That article hopefully did show me what i wasnt
doing...
For same reason i did look around for the instance of user control in the
data member declaration earlier and couldnt find it...
Anyho... have to map the instance on aspx page to the code behind.. then i
should be able to populate the properties.. (ealier was passing hard coded
values from within aspx and that worked)
Thanks mate,

Regards,

Hermit Dave

"John Timney (Microsoft MVP)" <timneyj@.despammed.com> wrote in message
news:Od4uotQwDHA.3496@.TK2MSFTNGP11.phx.gbl...
> You need to use properties and pass them in the page load events for
> example....
> Doug Stevens, another MVP has this very useful example whih explains the
> approach
>
http://www.dotnetjunkies.com/Articl...866F720AB013.dc
> ik
>
> --
> Regards
> John Timney (Microsoft ASP.NET MVP)
> --------------
> <shameless_author_plug>
> Professional .NET for Java Developers with C#
> ISBN:1-861007-91-4
> Professional Windows Forms
> ISBN: 1861005547
> Professional JSP 2nd Edition
> ISBN: 1861004958
> Professional JSP
> ISBN: 1861003625
> Beginning JSP Web Development
> ISBN: 1861002092
> </shameless_author_plug>
> --------------
> "Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
> news:uV5MEnQwDHA.556@.TK2MSFTNGP11.phx.gbl...
> > Hi,
> > Trying to pass a value to user control within a page.
> > 1. Couldnt find a way to pass it from code behind file.
> > 2. Trying to pass it from aspx page... using EditURL='<%
> > "mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
> > I have tried using a local variable... directly trying to read it off
> > Request object and even tried using session variable...
> > could be glad if someone could tell me how to get it right... thanks,
> > regards,
> > Hermit Dave
"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:uV5MEnQwDHA.556@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Trying to pass a value to user control within a page.
> 1. Couldnt find a way to pass it from code behind file.
> 2. Trying to pass it from aspx page... using EditURL='<%
> "mypage.aspx?myvar=" + myvalue %>' assigns value of EditURL=''
> I have tried using a local variable... directly trying to read it off
> Request object and even tried using session variable...
> could be glad if someone could tell me how to get it right... thanks,
> regards,
> Hermit Dave

I know you have already been pointed to the Properites as fits your
question.

Just as a side note though, you can also use a Cache object for passing
information to an from controls and web user controls. They are very handy.

--
Rocky Moore
www.HintsAndTips.com

pass value to user control from aspx

I have a user control:
- using LoadControl("MyCtrl.ascx")
MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx")
Page.Controls.Add(_mycontrol);
_mycontrol.Text
it will be loaded when some events fired.
so how can I pass value to this user control from aspx template file.Hi,
Create a property in user control and set the property in template file or
code file.
Prakash.C
"pei_world" wrote:

> I have a user control:
> - using LoadControl("MyCtrl.ascx")
> MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx")
> Page.Controls.Add(_mycontrol);
> _mycontrol.Text
> it will be loaded when some events fired.
> so how can I pass value to this user control from aspx template file.
>
>

pass value to user control from aspx

I have a user control:

- using LoadControl("MyCtrl.ascx")
MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx")
Page.Controls.Add(_mycontrol);
_mycontrol.Text

it will be loaded when some events fired.
so how can I pass value to this user control from aspx template file.Hi,

Create a property in user control and set the property in template file or
code file.

Prakash.C

"pei_world" wrote:

> I have a user control:
> - using LoadControl("MyCtrl.ascx")
> MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx")
> Page.Controls.Add(_mycontrol);
> _mycontrol.Text
> it will be loaded when some events fired.
> so how can I pass value to this user control from aspx template file.
>

Pass value to Web User Control

Say I have a user control like this one...
private Sections s = new Sections();

private void Page_Load(object sender, System.EventArgs e)
{
}

public Sections Sections
{
get { return s; }
set { s = value; }
}

public void f()
{
if (s.Query.Load())
while (s.MoveNext())
Response.Write(string.Format("<tr><td width='5'><img src='images/arrow.gif'></td><td><a href='showsections.aspx?s={0}'>{1}</a></td></tr>", s.SectionId, s.Title));
}
And I dragged the user control to index.aspx. Now, on page load of index.aspx, I want to pass some value to the user control's Section property. How do I do this? Or is this possible?

Thanks.If you have the User Control on the Page then you can simply use myUserControl.Sections = someValue; This is same as you would do for any other control on your page.
The thing is, even if i dragged the UserControl on my index.aspx, I can't seem to find SectionsControl (my web user control). At design mode though, I can see SectionsControl1 on index.aspx.

Am I missing something here?
Yes that is pretty much the behaviour you expect for any other control you add to a page. When you add a textbox control first time, the name of textbox will be textBox1 and second control will the name textBox2. In the same manner when you add a usercontrol, it will also follow the same behaviour. So in your code you should write this SectionsControl1.Sections = someValue;
It's a bug in VS 2003. You add a control to your page, but it fails to show up in your codebehind.

Go into the codebehind designer region, and declare your control (of the same name as on the page) with events.
Or, when you add your control to your page by dragging, save your page, THEN go into codebehind. It should show up there.
I missed this post last days. Sorry for the late reply. A bug that is, so decided to declare it myself. Thanks guys.

Pass values between 2 asp.net applications

I have two asp.net web applications.
The 1st appn has a login page and the other appln has other pages.
When the user logs from 1st appln, i want to pass the username to be passed to the other application.
I do not want to pass through query string.
Is there other way out. Please help!!!!!!!!!

SaifIs there a reason why they are in seperate apps?

However, to solve the problem you could try using a Cookie.

pass values back to parent window

I want to open up a little window so the user can choose something. So I wil
l
use javascript window.open to open up another aspx. However when they close
this i want to map some text box values on this page to some text box values
on the parent aspx. I have no idea how i would do this. any ideas? thank you
.hi louise,
u need to use window.opener function of javascript, chk this link for more
details :
http://www.vbcity.com/forums/topic...window%2Eopener
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:DF3969DD-0E61-47D3-8A76-B2D59CDDC474@.microsoft.com...
> I want to open up a little window so the user can choose something. So I
will
> use javascript window.open to open up another aspx. However when they
close
> this i want to map some text box values on this page to some text box
values
> on the parent aspx. I have no idea how i would do this. any ideas? thank
you.
very helpful. thank you.
"parshuram" wrote:

> hi louise,
> u need to use window.opener function of javascript, chk this link for more
> details :
> http://www.vbcity.com/forums/topic...window%2Eopener
> "louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
> message news:DF3969DD-0E61-47D3-8A76-B2D59CDDC474@.microsoft.com...
> will
> close
> values
> you.
>
>

pass values back to parent window

I want to open up a little window so the user can choose something. So I will
use javascript window.open to open up another aspx. However when they close
this i want to map some text box values on this page to some text box values
on the parent aspx. I have no idea how i would do this. any ideas? thank you.hi louise,

u need to use window.opener function of javascript, chk this link for more
details :

http://www.vbcity.com/forums/topic...window%2Eopener

"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:DF3969DD-0E61-47D3-8A76-B2D59CDDC474@.microsoft.com...
> I want to open up a little window so the user can choose something. So I
will
> use javascript window.open to open up another aspx. However when they
close
> this i want to map some text box values on this page to some text box
values
> on the parent aspx. I have no idea how i would do this. any ideas? thank
you.
very helpful. thank you.

"parshuram" wrote:

> hi louise,
> u need to use window.opener function of javascript, chk this link for more
> details :
> http://www.vbcity.com/forums/topic...window%2Eopener
> "louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
> message news:DF3969DD-0E61-47D3-8A76-B2D59CDDC474@.microsoft.com...
> > I want to open up a little window so the user can choose something. So I
> will
> > use javascript window.open to open up another aspx. However when they
> close
> > this i want to map some text box values on this page to some text box
> values
> > on the parent aspx. I have no idea how i would do this. any ideas? thank
> you.
>

Pass values from one user control to a user control on a different aspx page

Hello,

I have an aspx page titled Search.aspx. Within this page, I have a user control titled Search.ascx. I want a user to input search terms, then on the click of a button, I want to pass the values to another page (SearchResults.aspx)...which will then display the results in a user control.

Can someone please give me some suggestions on how to do this?

Thanks a lot!Hello, what you can do is:

inside ur usercontrol, create a method that returns a dataset or datareader. that is, since u are searching using the usercontrol, then the result of ur search will be returned by a method of type either dataset or datareader.

and in ur code-behind of the aspx page u can use it as follows:

protected Myusercontrol user;
private DataSet ds = user.GetResults();

and then u might want to put it in a session variable or xml file and then u will be able to access it from the SearchResults.aspx

but why do u want to show results in another page ?

Saturday, March 24, 2012

pass variable between webpage

I want to ask what is the best way to pass variable between asp.net we
pages, and user controls , any examples

-
dolla
----------------------
Posted via http://www.codecomments.co
----------------------Hi Dollar,

There are various ways in which ASP.NET helps you to pass information
from one page to another, it basically depends on your application.
In general, the applications use Session state to pass variables.

You can refer to the following link for complete details:

[State Management Recommendations]
http://msdn.microsoft.com/library/d...StateOption.asp

As for user controls, you can have public properties for the user control
which can be accessed by any page and also they will retain their values in
between
server round trips.

HTH

Mona[Grapecity]

"dollar" <dollar.1pp11p@.mail.codecomments.com> wrote in message
news:dollar.1pp11p@.mail.codecomments.com...
> I want to ask what is the best way to pass variable between asp.net web
> pages, and user controls , any examples?
>
> --
> dollar
> ----------------------
> Posted via http://www.codecomments.com
> ----------------------