Thursday, March 29, 2012

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 recordset from code-behind to aspx file

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?
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

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?

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
>

pass processing back to asp.dll

This summary is not available. Please click here to view the post.

Pass Recordset from Web Service to Classic ASP.

I want to use the .net Web Service to create a function and return the
datas (RecordSet). And want to retrived those data on the classic ASP.
Does any body have some example of this. How to create the Recordset in
webservice and get it at classic asp.
Thanks and Regards.Ted Ngo wrote:
> I want to use the .net Web Service to create a function and return the
> datas (RecordSet). And want to retrived those data on the classic ASP.
> Does any body have some example of this. How to create the Recordset
> in webservice and get it at classic asp.
> Thanks and Regards.
See this thread:
http://groups.google.com/group/micr...29ded2e3b036cec
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
so I using this
Or, you can send the XML of the ADO recordset back, and re-construct it
on
the client. Use Interop on the server to work with the ADO recordset.
// ON THE SERVER -- Web Service
// Add references to ADODB library
// Create a stream object
myStream = new ADODB.Stream();
// Replace the constants with their actual values
recordSet.Save(myStream, adPersistXML);
output = myStream.ReadText(adReadAll);
// Return the XML string, complete with schema
return output;
To return the recorset
and then on the asp using this to get the record set
Public Function RecordsetFromXMLString(sXML As String) As Recordset
Dim oStream As ADODB.Stream
Set oStream = New ADODB.Stream
oStream.Open
oStream.WriteText sXML 'Give the XML string to the ADO Stream
oStream.Position = 0 'Set the stream position to the start
Dim oRecordset As ADODB.Recordset
Set oRecordset = New ADODB.Recordset
oRecordset.Open oStream 'Open a recordset from the stream
oStream.Close
Set oStream = Nothing
Set RecordsetFromXMLString = oRecordset 'Return the recordset
Set oRecordset = Nothing
End Function
Is that righ?
Thanks
Yes, that's what I had in mind. Also, see Adam's last message in that
thread.
Bob
Ted Ngo wrote:
> so I using this
> Or, you can send the XML of the ADO recordset back, and re-construct
> it on
> the client. Use Interop on the server to work with the ADO recordset.
>
> // ON THE SERVER -- Web Service
> // Add references to ADODB library
>
> // Create a stream object
> myStream = new ADODB.Stream();
>
> // Replace the constants with their actual values
> recordSet.Save(myStream, adPersistXML);
> output = myStream.ReadText(adReadAll);
>
> // Return the XML string, complete with schema
> return output;
> To return the recorset
> and then on the asp using this to get the record set
> Public Function RecordsetFromXMLString(sXML As String) As Recordset
> Dim oStream As ADODB.Stream
> Set oStream = New ADODB.Stream
> oStream.Open
> oStream.WriteText sXML 'Give the XML string to the ADO Stream
> oStream.Position = 0 'Set the stream position to the start
> Dim oRecordset As ADODB.Recordset
> Set oRecordset = New ADODB.Recordset
> oRecordset.Open oStream 'Open a recordset from the stream
> oStream.Close
> Set oStream = Nothing
> Set RecordsetFromXMLString = oRecordset 'Return the recordset
> Set oRecordset = Nothing
> End Function
> Is that righ?
> Thanks
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

pass Selected Date in as a querystring

We are trying to pass the selected date from the .net calendar in a
querystring.response.redirect("http://MyUrl?date=" & Calendar1.SelectDate)

"Chanaka" <iwebprogram@.gmail.com> wrote in message
news:%23sgvzaSjFHA.2444@.tk2msftngp13.phx.gbl...
> We are trying to pass the selected date from the .net calendar in a
> querystring.

pass several parameters

Hello,

I am new with asp.net and I have some basic questions:

1What's the normal way of passing several server objets )(asp:text...)values to another page, when I click in a submit button.
(the same that we were doing in asp with the post.

2.I have a page where I have to do a search of the data of a peron by Id.
When the user click in the search button after givint the id, dO I have to bind each server control (in this case 5 <asp: testbox..>, name, surname, address, age, date birth) to the result of the query to retrieve the data?
How do I do that if my result is in a only query?

ThanksSee if below Link coule helps you. Seems you also have to do same kind of business ligic.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconPassingServerControlValuesBetweenPages.asp