Thursday, March 29, 2012
Pass Paramter from Repeater - Can't Figure This Out
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
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 recordset from code-behind to aspx file
I have established an adodb recordset in my code-behind, and I need to
pass it to the aspx file. I can't seem to figure out if there is a way
to do this. I see you can pass a string over using the
GetCallbackResult, but a recordset won't pass this way.
Any ideas?
ThanksIt doesn't even have to be a recordset. It could be an array, etc. I
need a way to pass variables, beyond strings, from the aspx.vb file to
the aspx file.
Has anyone done this? I can't seem to figure it out.
slowmotiongenius@.gmail.com wrote:
> All-
> I have established an adodb recordset in my code-behind, and I need to
> pass it to the aspx file. I can't seem to figure out if there is a way
> to do this. I see you can pass a string over using the
> GetCallbackResult, but a recordset won't pass this way.
> Any ideas?
>
> Thanks
Huh'
First, if you're using ADODB recordsets, you're probably doing something
wrong.
DataSets, IDataReaders are the "new" data model. If you used the upgrade
wizard, then I'd suggest refactoring that code.
..
You don't "pass" a datastore to the aspx file.
You usually put a control on the aspx page, and then bind it to a datasource
on the code behind page.
..
in 1.1, you'll do this
draw a datagrid on the aspx page.
on the page load
if (!Page.IsPostBack)
{
this.DataGrid1.DataSource = something;// where something is usually
a DataSet, IDataReader or an Array, or a CollectionBase
this.DataGrid1.DataBind();
}
asp.net is not an upgrade from asp. its a completely different animal
<slowmotiongenius@.gmail.com> wrote in message
news:1149866390.158704.78010@.g10g2000cwb.googlegroups.com...
> It doesn't even have to be a recordset. It could be an array, etc. I
> need a way to pass variables, beyond strings, from the aspx.vb file to
> the aspx file.
> Has anyone done this? I can't seem to figure it out.
>
> slowmotiongenius@.gmail.com wrote:
>
slowmotiongenius@.gmail.com wrote:
> All-
> I have established an adodb recordset in my code-behind, and I need to
> pass it to the aspx file. I can't seem to figure out if there is a way
> to do this. I see you can pass a string over using the
> GetCallbackResult, but a recordset won't pass this way.
>
If you really have an adodb.recordset, then you must be using interop,
right?
Anyways, you can do something like this:
http://www.davidpenton.com/testsite...rver2client.asp
or this, if you don't really need the recordset functionality:
http://www.davidpenton.com/testsite...ata.islands.asp
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Sorry, I'm using an adodb recordset because I wanted to set the
datasource of an office web component Pivottable equal to one. I read
that you could only use an xml file, a office web component data source
control, or a recordset. There was no mention of being able to use a
DataSet.
Now I can't draw the control for the Pivottable on the aspx page. I
have to place this in the aspx file
<-object classid="clsid:0002E552-0000-0000-C000-000000000046"
id="Pivot1" height="300" width="600"></object>
or do a response.write("<object
classid="clsid:0002E552-0000-0000-C000-000000000046" id="Pivot1"
height="300" width="600"></object>") in the aspx.vb pivottable.
Either way, the control isn't something that I can reference in the
aspx.vb by saying
Pivot1.DataSource = XXXXXXX
So I need to response.write("Pivot1.Datasource = " + adodbRS)
or some way to pass the record set over to the aspx file so I can
assign the datasource of the pivot table to it.
Does this make sense? Any way to accomplish something like this?
Thanks for the response!
sloan wrote:
> Huh'
> First, if you're using ADODB recordsets, you're probably doing something
> wrong.
> DataSets, IDataReaders are the "new" data model. If you used the upgrade
> wizard, then I'd suggest refactoring that code.
> ..
> You don't "pass" a datastore to the aspx file.
> You usually put a control on the aspx page, and then bind it to a datasour
ce
> on the code behind page.
> ..
> in 1.1, you'll do this
> draw a datagrid on the aspx page.
> on the page load
> if (!Page.IsPostBack)
> {
> this.DataGrid1.DataSource = something;// where something is usuall
y
> a DataSet, IDataReader or an Array, or a CollectionBase
> this.DataGrid1.DataBind();
> }
>
> asp.net is not an upgrade from asp. its a completely different animal
>
> <slowmotiongenius@.gmail.com> wrote in message
> news:1149866390.158704.78010@.g10g2000cwb.googlegroups.com...
Someone has to have needed to do something like this in the past...any
tips on passing a recordset/dataset from the code-behind to the aspx
page?
slowmotiongenius@.gmail.com wrote:
> Sorry, I'm using an adodb recordset because I wanted to set the
> datasource of an office web component Pivottable equal to one. I read
> that you could only use an xml file, a office web component data source
> control, or a recordset. There was no mention of being able to use a
> DataSet.
> Now I can't draw the control for the Pivottable on the aspx page. I
> have to place this in the aspx file
> <-object classid="clsid:0002E552-0000-0000-C000-000000000046"
> id="Pivot1" height="300" width="600"></object>
> or do a response.write("<object
> classid="clsid:0002E552-0000-0000-C000-000000000046" id="Pivot1"
> height="300" width="600"></object>") in the aspx.vb pivottable.
> Either way, the control isn't something that I can reference in the
> aspx.vb by saying
> Pivot1.DataSource = XXXXXXX
> So I need to response.write("Pivot1.Datasource = " + adodbRS)
> or some way to pass the record set over to the aspx file so I can
> assign the datasource of the pivot table to it.
> Does this make sense? Any way to accomplish something like this?
> Thanks for the response!
>
> sloan wrote:
Pass recordset from code-behind to aspx file
I have established an adodb recordset in my code-behind, and I need to
pass it to the aspx file. I can't seem to figure out if there is a way
to do this. I see you can pass a string over using the
GetCallbackResult, but a recordset won't pass this way.
Any ideas?
ThanksIt doesn't even have to be a recordset. It could be an array, etc. I
need a way to pass variables, beyond strings, from the aspx.vb file to
the aspx file.
Has anyone done this? I can't seem to figure it out.
slowmotiongenius@.gmail.com wrote:
> All-
> I have established an adodb recordset in my code-behind, and I need to
> pass it to the aspx file. I can't seem to figure out if there is a way
> to do this. I see you can pass a string over using the
> GetCallbackResult, but a recordset won't pass this way.
> Any ideas?
>
> Thanks
Huh??
First, if you're using ADODB recordsets, you're probably doing something
wrong.
DataSets, IDataReaders are the "new" data model. If you used the upgrade
wizard, then I'd suggest refactoring that code.
...
You don't "pass" a datastore to the aspx file.
You usually put a control on the aspx page, and then bind it to a datasource
on the code behind page.
...
in 1.1, you'll do this
draw a datagrid on the aspx page.
on the page load
if (!Page.IsPostBack)
{
this.DataGrid1.DataSource = something;// where something is usually
a DataSet, IDataReader or an Array, or a CollectionBase
this.DataGrid1.DataBind();
}
asp.net is not an upgrade from asp. its a completely different animal
<slowmotiongenius@.gmail.com> wrote in message
news:1149866390.158704.78010@.g10g2000cwb.googlegro ups.com...
> It doesn't even have to be a recordset. It could be an array, etc. I
> need a way to pass variables, beyond strings, from the aspx.vb file to
> the aspx file.
> Has anyone done this? I can't seem to figure it out.
>
> slowmotiongenius@.gmail.com wrote:
> > All-
> > I have established an adodb recordset in my code-behind, and I need to
> > pass it to the aspx file. I can't seem to figure out if there is a way
> > to do this. I see you can pass a string over using the
> > GetCallbackResult, but a recordset won't pass this way.
> > Any ideas?
> > Thanks
slowmotiongenius@.gmail.com wrote:
> All-
> I have established an adodb recordset in my code-behind, and I need to
> pass it to the aspx file. I can't seem to figure out if there is a way
> to do this. I see you can pass a string over using the
> GetCallbackResult, but a recordset won't pass this way.
If you really have an adodb.recordset, then you must be using interop,
right?
Anyways, you can do something like this:
http://www.davidpenton.com/testsite...rver2client.asp
or this, if you don't really need the recordset functionality:
http://www.davidpenton.com/testsite...ata.islands.asp
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Sorry, I'm using an adodb recordset because I wanted to set the
datasource of an office web component Pivottable equal to one. I read
that you could only use an xml file, a office web component data source
control, or a recordset. There was no mention of being able to use a
DataSet.
Now I can't draw the control for the Pivottable on the aspx page. I
have to place this in the aspx file
<-object classid="clsid:0002E552-0000-0000-C000-000000000046"
id="Pivot1" height="300" width="600"></object
or do a response.write("<object
classid="clsid:0002E552-0000-0000-C000-000000000046" id="Pivot1"
height="300" width="600"></object>") in the aspx.vb pivottable.
Either way, the control isn't something that I can reference in the
aspx.vb by saying
Pivot1.DataSource = XXXXXXX
So I need to response.write("Pivot1.Datasource = " + adodbRS)
or some way to pass the record set over to the aspx file so I can
assign the datasource of the pivot table to it.
Does this make sense? Any way to accomplish something like this?
Thanks for the response!
sloan wrote:
> Huh??
> First, if you're using ADODB recordsets, you're probably doing something
> wrong.
> DataSets, IDataReaders are the "new" data model. If you used the upgrade
> wizard, then I'd suggest refactoring that code.
> ..
> You don't "pass" a datastore to the aspx file.
> You usually put a control on the aspx page, and then bind it to a datasource
> on the code behind page.
> ..
> in 1.1, you'll do this
> draw a datagrid on the aspx page.
> on the page load
> if (!Page.IsPostBack)
> {
> this.DataGrid1.DataSource = something;// where something is usually
> a DataSet, IDataReader or an Array, or a CollectionBase
> this.DataGrid1.DataBind();
> }
>
> asp.net is not an upgrade from asp. its a completely different animal
>
> <slowmotiongenius@.gmail.com> wrote in message
> news:1149866390.158704.78010@.g10g2000cwb.googlegro ups.com...
> > It doesn't even have to be a recordset. It could be an array, etc. I
> > need a way to pass variables, beyond strings, from the aspx.vb file to
> > the aspx file.
> > Has anyone done this? I can't seem to figure it out.
> > slowmotiongenius@.gmail.com wrote:
> > > All-
> > > I have established an adodb recordset in my code-behind, and I need to
> > > pass it to the aspx file. I can't seem to figure out if there is a way
> > > to do this. I see you can pass a string over using the
> > > GetCallbackResult, but a recordset won't pass this way.
> > > > Any ideas?
> > > > > Thanks
Someone has to have needed to do something like this in the past...any
tips on passing a recordset/dataset from the code-behind to the aspx
page?
slowmotiongenius@.gmail.com wrote:
> Sorry, I'm using an adodb recordset because I wanted to set the
> datasource of an office web component Pivottable equal to one. I read
> that you could only use an xml file, a office web component data source
> control, or a recordset. There was no mention of being able to use a
> DataSet.
> Now I can't draw the control for the Pivottable on the aspx page. I
> have to place this in the aspx file
> <-object classid="clsid:0002E552-0000-0000-C000-000000000046"
> id="Pivot1" height="300" width="600"></object>
> or do a response.write("<object
> classid="clsid:0002E552-0000-0000-C000-000000000046" id="Pivot1"
> height="300" width="600"></object>") in the aspx.vb pivottable.
> Either way, the control isn't something that I can reference in the
> aspx.vb by saying
> Pivot1.DataSource = XXXXXXX
> So I need to response.write("Pivot1.Datasource = " + adodbRS)
> or some way to pass the record set over to the aspx file so I can
> assign the datasource of the pivot table to it.
> Does this make sense? Any way to accomplish something like this?
> Thanks for the response!
>
> sloan wrote:
> > Huh??
> > First, if you're using ADODB recordsets, you're probably doing something
> > wrong.
> > DataSets, IDataReaders are the "new" data model. If you used the upgrade
> > wizard, then I'd suggest refactoring that code.
> > ..
> > You don't "pass" a datastore to the aspx file.
> > You usually put a control on the aspx page, and then bind it to a datasource
> > on the code behind page.
> > ..
> > in 1.1, you'll do this
> > draw a datagrid on the aspx page.
> > on the page load
> > if (!Page.IsPostBack)
> > {
> > this.DataGrid1.DataSource = something;// where something is usually
> > a DataSet, IDataReader or an Array, or a CollectionBase
> > this.DataGrid1.DataBind();
> > }
> > asp.net is not an upgrade from asp. its a completely different animal
> > <slowmotiongenius@.gmail.com> wrote in message
> > news:1149866390.158704.78010@.g10g2000cwb.googlegro ups.com...
> > > It doesn't even have to be a recordset. It could be an array, etc. I
> > > need a way to pass variables, beyond strings, from the aspx.vb file to
> > > the aspx file.
> > > > Has anyone done this? I can't seem to figure it out.
> > > > > slowmotiongenius@.gmail.com wrote:
> > > > All-
> > > > I have established an adodb recordset in my code-behind, and I need to
> > > > pass it to the aspx file. I can't seem to figure out if there is a way
> > > > to do this. I see you can pass a string over using the
> > > > GetCallbackResult, but a recordset won't pass this way.
> > > > > > Any ideas?
> > > > > > > > Thanks
>
Wednesday, March 21, 2012
Passing a GUID to another page
I would like to figure out the solution to this problem.
Compilation Error
Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message:BC30311: Value of type 'System.Guid' cannot be converted to 'String'.
Source Error:
Line 348: <asp:TemplateField SortExpression="avatar">Line 349:<ItemTemplate>Line 350:<asp:Image ID="Image1" runat="server" ImageUrl='<%# "AvatarImagefetch.ashx?UserName=" & CStr(new Guid(Eval("UserID").ToString()))) %>'/>Line 351:</ItemTemplate>Line 352:Now I have tried several variations to this theme.
Basically I want to convert "USERID" which is a GUID to a String before passing it to another page.
This is part of a Gridview.
Try this for ImageUrl (I am assuming you are using VB.NET from CStr)
<%# String.Concat("AvatarImagefetch.ashx?Username=", Eval("UserID"))%> You don't need to cast Eval("UserID") as a Guid, you can leave it is an object because if it is a Guid you will just end up turning it back into a string.Hi Kevin,
Thanks for the tip, I was reaserching this prior to your reply and found the following to work:
<
ItemTemplate><
asp:ImageID="Image1"runat="server"ImageUrl='<%# "AvatarImagefetch.ashx?MemberId=" & DataBinder.Eval(Container.DataItem,"UserId").ToString %>'/></
ItemTemplate>I think you need the .ToString for it to be passed as a String.
I used String.Concat, and Concat can accept object and will automatically convert them to a string.
That is excellent tip, thanks once again Kevin.
Friday, March 16, 2012
Passing a variable in the onLoad event.
it to select the correct item for each row. What I am trying to figure out,
is can I pass a value to the onLoad event for the dropdownlist?
OnLoad="loadDefault(Container.DataItem("dropValue"))"Are you trying to put a selected index?
"Robin Bonin" <robin@.guavatools.com> wrote in message
news:Sr6dnWpfNfAlKIiiXTWJiA@.eatel.net...
> I have a data grid with multiple rows. Each row has a drop down box. I
need
> it to select the correct item for each row. What I am trying to figure
out,
> is can I pass a value to the onLoad event for the dropdownlist?
> OnLoad="loadDefault(Container.DataItem("dropValue"))"
I know the value of the selectedIndex, and that is what I'm trying to
select.
"Cristian Suazo" <crillus7@.hotmail.com> wrote in message
news:O$93Kq9SDHA.1724@.TK2MSFTNGP10.phx.gbl...
> Are you trying to put a selected index?
> "Robin Bonin" <robin@.guavatools.com> wrote in message
> news:Sr6dnWpfNfAlKIiiXTWJiA@.eatel.net...
> > I have a data grid with multiple rows. Each row has a drop down box. I
> need
> > it to select the correct item for each row. What I am trying to figure
> out,
> > is can I pass a value to the onLoad event for the dropdownlist?
> > OnLoad="loadDefault(Container.DataItem("dropValue"))"
Just set the selected index in the code behind: myDropDown.SelectedIndex =
intSelectedIndex
--
S. Justin Gengo, MCP
Web Developer / Programmer
Free Code Library At:
www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Robin Bonin" <robin@.guavatools.com> wrote in message
news:foidna-hLOZ1JIiiXTWJjg@.eatel.net...
> I know the value of the selectedIndex, and that is what I'm trying to
> select.
>
> "Cristian Suazo" <crillus7@.hotmail.com> wrote in message
> news:O$93Kq9SDHA.1724@.TK2MSFTNGP10.phx.gbl...
> > Are you trying to put a selected index?
> > "Robin Bonin" <robin@.guavatools.com> wrote in message
> > news:Sr6dnWpfNfAlKIiiXTWJiA@.eatel.net...
> > > I have a data grid with multiple rows. Each row has a drop down box. I
> > need
> > > it to select the correct item for each row. What I am trying to figure
> > out,
> > > is can I pass a value to the onLoad event for the dropdownlist?
> > > > OnLoad="loadDefault(Container.DataItem("dropValue"))"
> >
Passing a variable: options
Hi, I am trying to pass three variables from a main page to a pop up window: I have a few options, but I can't figure out which to use! Here is what I am using to generate the new popup page:
<ahref="javascript:;"onclick="window.open('_search.aspx','child')">Search</a>
Is there a way to do this using <asp:button...> ? The problem is simply cosmetic.
Anways, back to my options:
1) A cookie. It's a very small page and I've never used cookies till now, so I don't want it to get overly complicated. I just need to pass the text values of three variables to this new window.
2) Using what I found through browsing the forums, I think this is using SessionID (can someone let me know if it is?):
On parent page: Session("var1")=newString
On child page: dim newString As String = Session("var1")
How does that work? Is this information stored in the cache on client/server? Does it use SessionID?
3) Response.Redirect("page.aspx", false) - this would work, as I believe it does not call Response.End() in that case, but how can this open a new window?
Thanks for your time!
James
To pass the varaibles in between pages, you can use session variables..
Try this code.. here i am passing 4 variabels from main page to PopUp window..
In Form1:
privatevoid Button1_Click(object sender, System.EventArgs e)
{
Session["name"]=TextBox1.Text;
Session["add"]=TextBox2.Text;
Session["phoneNum"]=TextBox3.Text;
Session["email"]=TextBox4.Text;
}
In PopupWindow:
privatevoid Page_Load(object sender, System.EventArgs e)
{
Label1.Text=Session["name"].ToString();
Label2.Text=Session["add"].ToString();
Label3.Text=Session["phoneNum"].ToString();
Label4.Text=Session["email"].ToString();
}
Hope it helps..
I think you generally use cookies only if you need to persist the data.
When a user starts a session, the data area for that user gets created. Storing values in session variables such as you show in #2 is a common way to do what you are trying to do. This area is unique to the user and stored on the server.
Response.redirect redirects your browser to the new page. It does not open a new window.
Also, depending on the size and type of data you need to pass, you might look into using a querystring as well.
1) cookies are just as easy to set as a session var.
2) session will work fine.
3) response.redirect CANT open a new window, its a server call
Have you looked at the QueryString option? ...page.aspx?id=myVar
This will pass the var directly to the page.
You could also store the var in a table/db, then read that field on the new page.
Lots of ways to do this.
Hey, thanks for the help. I had looked at QeryString, but I want to pass multiple variables and I was getting errors. Now, that may have had to do with my implementation :) I will look into these options - thanks again!
James
...page.aspx?var1=Nice&var2=Nicer&var3=Nicest
Great! Thanks :)
Alright, I ended up passing over the QueryStrings in order to use session variables. At this point though, there's a small issue I'd like to fix. When I click the button, I open a new page via this script:
PublicSub newSearch_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)
Dim jScriptStringAsString
jScriptString ="<SCR" +"IPT>"
jScriptString +="window.open('_search.aspx');"
jScriptString +="</SCR" +"IPT>"
Session("resultOrg") = searchOrg.Text
Session("resultCert") = searchCert.Text
Session("resultID") = searchID.Text
Response.Write(jScriptString)
EndSub
This new page has the session variables and can do what I need with it. However, when I click the search, the parent page executes a postback - while this is only a small annoyance, it seems to be a wasteful way to program. Is there a way to disable the postback on this particular button click? I've tried HTML buttons, but get "error on page" -
<buttonclass="Button"type="button"onclick="newSearch_Click"runat="server">Search</button>
<asp:ButtonID="searchButton"Text="Search"CssClass="Button"runat="server"OnClick="newSearch_Click"/>
couple options, but if you want to have the Session variable set FROM CODEBEHIND then you will have to do a postback...
Hi
Why the following instrution donesn't work?
Response.Redirect("inventario.aspx?quem=" + (GridView1.Rows(0).Cells(0).Text) &"nivel=" + (Passe_txt.Text))
I only get thequem value. The variablenivel is empty
Other question: How can i use request.form() in aspx?
Thank you
Found the solution
Response.Redirect("inventario.aspx?quem=" + (GridView1.Rows(0).Cells(0).Text) &"&nivel=" + (Passe_txt.Text))