Showing posts with label parameter. Show all posts
Showing posts with label parameter. Show all posts

Monday, March 26, 2012

passing variable to the Parameter value of ObjectDataSource1?

How do I go about passing the value strUserId to the parameter value of ObjectDataSource1?

// get userid for logged in client
if (User.Identity.IsAuthenticated)
{
strUserId = Membership.GetUser().ProviderUserKey.ToString();
}

In the Configure Data Source wizard it is asking for a Parameter Source in the drop down. And the variable strUserId (in the code-behind for the page) is not an option.

How do I make it one?

hi

you need to set the parameter value in Selecting event of the object datasource :

protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) {this.ObjectDataSource1.SelectParameters[0].DefaultValue = Membership.GetUser().ProviderUserKey(); }


Try setting your Parameter in the ObjectDataSource.Selecting event like so:

protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e){e.InputParameters["UserID"] = Membership.GetUser().ProviderUserKey;}

Thank you Anas,

I double clicked the ObjectDataSource1 in design view and was able to get it started.

I will review your code.

Thanks again.

Update: I actually got the 2nd answer in this thread to work.

Saturday, March 24, 2012

Passing variables between Server scripts and client scripts!

Hi,

I am having difficulty in passing a variable from a server script to a client script. I am looking to take a parameter that is passed into an ASP page from another page and use this parameter in a client side script.Is it possible to do this?? A simplified version of what I want to do is:

<%
Dim Tag
Tag = Request.QueryString("ID")
%>
........

<%Script Language="VBScript">
Dim Tag2
Tag2 = <%=Tag%>
document.write(Tag2)
<Script
Any help greatly appreciated!!1. need quotes around the literal value in client script
2. need to close your Script tag

<%
Dim Tag as String = Request("ID")
%
<Script Language="VBScript">
Dim Tag2
Tag2 = "<%= Tag %>"
document.write(Tag2)
</Script>

Thank you very much!! Works a treat.

Wednesday, March 21, 2012

Passing XML as parameter to Web page

I must be missing something, because this should be easy to do.
After the user has selected several options on a page, I do a database query
which returns a few records that I want to pass to another page via XML. Ho
w
do I do this?
I typically Response.Redirect around my app, including various parameters.
Do I just include the XML as a parameter as in:
Response.Redirect("page.aspx?" & ds.WriteXML)
That just doesn't seem right.
If you would be so kind as to include both what the sending and receiving
should be doing in any example it would be greatly appreciated!So you have a page, "Page1" which captures some criteria, and then performs
a database query, and passes those results to "Page2" for display.
If it's a particularly small amount of XML, I suppose you could use the
query string, though you want to encode your querystring;
Response.Redirect("page.aspx?" & Server.UrlEncode (ds.WriteXML))
But that seems like a particularly risky way to use a querystring.
It makes more sense to me collect your criteria in Page1, then pass the
actual query parameters to Page2, and have Page2 do the query itself. In
most cases the query params will take much less space to transmit than the
query results. Also it makes Page2 more generally usable [barring special
security concerns].
Another option is to do the query, cache either the query or the result in
the database, and then pass the queryID to Page2. That's a useful approach
for very large complex queries, especially if you want to keep a history of
queries a user has run. I use that for real-estate sites, where the user
can have hundreds of criteria, and the broker needs to know what the
customer is searching for.
/// M
"Steven J. Reed" <StevenJReed@.discussions.microsoft.com> wrote in message
news:61770068-C646-4FE1-80F3-E4C5451DD1E0@.microsoft.com...
> I must be missing something, because this should be easy to do.
> After the user has selected several options on a page, I do a database
query
> which returns a few records that I want to pass to another page via XML.
How
> do I do this?
> I typically Response.Redirect around my app, including various
parameters.
> Do I just include the XML as a parameter as in:
> Response.Redirect("page.aspx?" & ds.WriteXML)
> That just doesn't seem right.
> If you would be so kind as to include both what the sending and receiving
> should be doing in any example it would be greatly appreciated!
Can you use “Session”? You can store XML as DOM object or string in Sess
ion,
and pass Session state to next page, or next of next page. Session is a
popular way to carry data to next page in ASP.NET.
Shaw
"MWells" wrote:

> So you have a page, "Page1" which captures some criteria, and then perform
s
> a database query, and passes those results to "Page2" for display.
> If it's a particularly small amount of XML, I suppose you could use the
> query string, though you want to encode your querystring;
> Response.Redirect("page.aspx?" & Server.UrlEncode (ds.WriteXML))
> But that seems like a particularly risky way to use a querystring.
> It makes more sense to me collect your criteria in Page1, then pass the
> actual query parameters to Page2, and have Page2 do the query itself. In
> most cases the query params will take much less space to transmit than the
> query results. Also it makes Page2 more generally usable [barring special
> security concerns].
> Another option is to do the query, cache either the query or the result in
> the database, and then pass the queryID to Page2. That's a useful approac
h
> for very large complex queries, especially if you want to keep a history o
f
> queries a user has run. I use that for real-estate sites, where the user
> can have hundreds of criteria, and the broker needs to know what the
> customer is searching for.
> /// M
>
> "Steven J. Reed" <StevenJReed@.discussions.microsoft.com> wrote in message
> news:61770068-C646-4FE1-80F3-E4C5451DD1E0@.microsoft.com...
> query
> How
> parameters.
>
>
Thank you both for your responses. I guess you confirmed my suspicions: you
can't pass a stream as the parameter. I will have to pass the text.
I didn't say it in my original post, but there are a couple of reasons I
can't just do the query in Page2. 1) The database query must be kept
independent from the processing due to manipulation of the data and the fact
the data may be coming from multiple sources. 2) Page2 may be on a
different server. 3) Page2 is actually a few different pages, so the desir
e
is that the query done in Page1 passes common data to subsequent pages.
...Steve
"Shaw" wrote:
> Can you use “Session”? You can store XML as DOM object or string in Se
ssion,
> and pass Session state to next page, or next of next page. Session is a
> popular way to carry data to next page in ASP.NET.
> Shaw
>
> "MWells" wrote:
>

Passing XML as parameter to Web page

I must be missing something, because this should be easy to do.

After the user has selected several options on a page, I do a database query
which returns a few records that I want to pass to another page via XML. How
do I do this?

I typically Response.Redirect around my app, including various parameters.
Do I just include the XML as a parameter as in:
Response.Redirect("page.aspx?" & ds.WriteXML)

That just doesn't seem right.

If you would be so kind as to include both what the sending and receiving
should be doing in any example it would be greatly appreciated!So you have a page, "Page1" which captures some criteria, and then performs
a database query, and passes those results to "Page2" for display.

If it's a particularly small amount of XML, I suppose you could use the
query string, though you want to encode your querystring;

Response.Redirect("page.aspx?" & Server.UrlEncode (ds.WriteXML))

But that seems like a particularly risky way to use a querystring.

It makes more sense to me collect your criteria in Page1, then pass the
actual query parameters to Page2, and have Page2 do the query itself. In
most cases the query params will take much less space to transmit than the
query results. Also it makes Page2 more generally usable [barring special
security concerns].

Another option is to do the query, cache either the query or the result in
the database, and then pass the queryID to Page2. That's a useful approach
for very large complex queries, especially if you want to keep a history of
queries a user has run. I use that for real-estate sites, where the user
can have hundreds of criteria, and the broker needs to know what the
customer is searching for.

/// M

"Steven J. Reed" <StevenJReed@.discussions.microsoft.com> wrote in message
news:61770068-C646-4FE1-80F3-E4C5451DD1E0@.microsoft.com...
> I must be missing something, because this should be easy to do.
> After the user has selected several options on a page, I do a database
query
> which returns a few records that I want to pass to another page via XML.
How
> do I do this?
> I typically Response.Redirect around my app, including various
parameters.
> Do I just include the XML as a parameter as in:
> Response.Redirect("page.aspx?" & ds.WriteXML)
> That just doesn't seem right.
> If you would be so kind as to include both what the sending and receiving
> should be doing in any example it would be greatly appreciated!
Can you use "Session"? You can store XML as DOM object or string in Session,
and pass Session state to next page, or next of next page. Session is a
popular way to carry data to next page in ASP.NET.

Shaw

"MWells" wrote:

> So you have a page, "Page1" which captures some criteria, and then performs
> a database query, and passes those results to "Page2" for display.
> If it's a particularly small amount of XML, I suppose you could use the
> query string, though you want to encode your querystring;
> Response.Redirect("page.aspx?" & Server.UrlEncode (ds.WriteXML))
> But that seems like a particularly risky way to use a querystring.
> It makes more sense to me collect your criteria in Page1, then pass the
> actual query parameters to Page2, and have Page2 do the query itself. In
> most cases the query params will take much less space to transmit than the
> query results. Also it makes Page2 more generally usable [barring special
> security concerns].
> Another option is to do the query, cache either the query or the result in
> the database, and then pass the queryID to Page2. That's a useful approach
> for very large complex queries, especially if you want to keep a history of
> queries a user has run. I use that for real-estate sites, where the user
> can have hundreds of criteria, and the broker needs to know what the
> customer is searching for.
> /// M
>
> "Steven J. Reed" <StevenJReed@.discussions.microsoft.com> wrote in message
> news:61770068-C646-4FE1-80F3-E4C5451DD1E0@.microsoft.com...
> > I must be missing something, because this should be easy to do.
> > After the user has selected several options on a page, I do a database
> query
> > which returns a few records that I want to pass to another page via XML.
> How
> > do I do this?
> > I typically Response.Redirect around my app, including various
> parameters.
> > Do I just include the XML as a parameter as in:
> > Response.Redirect("page.aspx?" & ds.WriteXML)
> > That just doesn't seem right.
> > If you would be so kind as to include both what the sending and receiving
> > should be doing in any example it would be greatly appreciated!
>
Thank you both for your responses. I guess you confirmed my suspicions: you
can't pass a stream as the parameter. I will have to pass the text.

I didn't say it in my original post, but there are a couple of reasons I
can't just do the query in Page2. 1) The database query must be kept
independent from the processing due to manipulation of the data and the fact
the data may be coming from multiple sources. 2) Page2 may be on a
different server. 3) Page2 is actually a few different pages, so the desire
is that the query done in Page1 passes common data to subsequent pages.

...Steve

"Shaw" wrote:

> Can you use "Session"? You can store XML as DOM object or string in Session,
> and pass Session state to next page, or next of next page. Session is a
> popular way to carry data to next page in ASP.NET.
> Shaw
>
> "MWells" wrote:
> > So you have a page, "Page1" which captures some criteria, and then performs
> > a database query, and passes those results to "Page2" for display.
> > If it's a particularly small amount of XML, I suppose you could use the
> > query string, though you want to encode your querystring;
> > Response.Redirect("page.aspx?" & Server.UrlEncode (ds.WriteXML))
> > But that seems like a particularly risky way to use a querystring.
> > It makes more sense to me collect your criteria in Page1, then pass the
> > actual query parameters to Page2, and have Page2 do the query itself. In
> > most cases the query params will take much less space to transmit than the
> > query results. Also it makes Page2 more generally usable [barring special
> > security concerns].
> > Another option is to do the query, cache either the query or the result in
> > the database, and then pass the queryID to Page2. That's a useful approach
> > for very large complex queries, especially if you want to keep a history of
> > queries a user has run. I use that for real-estate sites, where the user
> > can have hundreds of criteria, and the broker needs to know what the
> > customer is searching for.
> > /// M
> > "Steven J. Reed" <StevenJReed@.discussions.microsoft.com> wrote in message
> > news:61770068-C646-4FE1-80F3-E4C5451DD1E0@.microsoft.com...
> > > I must be missing something, because this should be easy to do.
> > > > After the user has selected several options on a page, I do a database
> > query
> > > which returns a few records that I want to pass to another page via XML.
> > How
> > > do I do this?
> > > > I typically Response.Redirect around my app, including various
> > parameters.
> > > Do I just include the XML as a parameter as in:
> > > Response.Redirect("page.aspx?" & ds.WriteXML)
> > > > That just doesn't seem right.
> > > > If you would be so kind as to include both what the sending and receiving
> > > should be doing in any example it would be greatly appreciated!

Passing xml document to Oracle Stored Procedure

Please recommend any sources that help write stored procedure with an xml document as an input parameter for Oracle. Thanks.

You would have to use VARCHAR() data type to your XML document.