Thursday, March 29, 2012

Pass information through URL

Hi Guys,

I am trying to pass information through a URL. I have seen a VB example like

<a href="http://links.10026.com/?link=details.aspx?id={0}", Container.DataItem("EmployeeID"

Is the {0} supposed to be a placeholder or something?

Then in C#, i tried to just go something like

<a href='details.aspx?id=<%#DataBinder.Eval(Container.DataItem, "author_ID") %>'><%#DataBinder.Eval(Container.DataItem, "au_lname")%></a><br /
And it works like it should..

Does anyone have a reference of how to properly pass variables through a URL like this?
Or.. what is the proper name of this?

ThanksI am not sure exactly what you are looking for. This is the most basic way of passing variables to a web page. It is based on the GET method which appends the variable id and value to the URL string. There are a number of security issues with this method, as the variable values in plain text and viewable to the user and the amount of data that can be sent is restricted by the maximum allowed length of the URL string, usually 256 chars. However it's simplicity usually makes it useable in some situations.

The other method to pass variables to a web page is through the POST method. This is more secure and more information can be passed.
Hmm.. well thanks for the security warning but, still how would you do this? Security is not an issue at this point for this.

With C#, are you supposed to use a ?id={0} thing, or just skip the {0}, what is that even doing in VB.NET?

Thanks
Oh I see what you are asking now. Basically there is no correct way to build up the URL string, you can concatenate strings or even use a StringBuilder. As long as you build a URL string that is valid.

In the VB example the {0} is indeed a place holder that is replaced by the variable positioned after the ",". In your case the value of Container.DataItem("EmployeeID" ).

In C# I think you can use the {0} thing as well or you could use any of the other string concatenation symbols like the overloaded + operator.

A valid URL string is of the form:
[the URL] ie the webpage that you want to go to
? this indicates that GET variables are about to follow
name1 the name of the first variable
= equals
value1 the value of the first variable
& indicates the start of another variable
name2
=
value2

and so on.
Ah.. thanks

Is there some advantage in using the {0} over just leaving it out?

Pass information from XML file to ASPX page

Hello,
I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?
Thanks in advance for help,
uservoidHi evangelous,
Maybe this can help you:
http://www.planet-source-code.com/v...gWId=10

Guillermo G.
----
--
Guillermo Gonzlez Arroyave :: MCP ASP.Net C# :: DCE4
<evangelous@.gmail.com> wrote in message news:1122017876.519551.161420@.g49g20
00cwa.googlegroups.com...
Hello,
I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?
Thanks in advance for help,
uservoid

Pass information from XML file to ASPX page

Hello,

I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?

Thanks in advance for help,
uservoidHi evangelous,

Maybe this can help you:
http://www.planet-source-code.com/v...=3753&lngWId=10

Guillermo G.

------------------------
Guillermo Gonzlez Arroyave :: MCP ASP.Net C# :: DCE4

<evangelous@.gmail.com> wrote in message news:1122017876.519551.161420@.g49g2000cwa.googlegr oups.com...
Hello,

I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?

Thanks in advance for help,
uservoid

pass javascript object reference to a session object

How can I pass a javascript object reference
var win1 = window.open( ...)
to a Session object
Session["obj1"] =
in a .aspx pageIt is not possible.
Session objects are stored on the server. Client objects are storied on the
client. You can only send text-data. Keep a window open that will hold your
references if you need to.
-- Alex
"mg" wrote:

> How can I pass a javascript object reference
> var win1 = window.open( ...)
> to a Session object
> Session["obj1"] =
> in a .aspx page
Could you be more specific?
Thanks.
"Alex Papadimoulis" wrote:
> It is not possible.
> Session objects are stored on the server. Client objects are storied on th
e
> client. You can only send text-data. Keep a window open that will hold you
r
> references if you need to.
> -- Alex
> "mg" wrote:
>
You cannot pass a window object to the Session object. If you provide more
information about what you are trying to do, someone might be able to help
you better.
Girish Bharadwaj
http://msmvps.com/gbvb
"mg" <mg@.discussions.microsoft.com> wrote in message
news:BA28CC96-461E-41F5-8AE8-06DE179F1CD4@.microsoft.com...
> Could you be more specific?
> Thanks.
> "Alex Papadimoulis" wrote:
>
the
your
What exactly fo you want to do..
Explain maybe i can HELP!
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

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 login info back from web service

I am trying to build a web service and link it to my site for authenitcation of users

works fine as long as i am check for a boolean

what i want to do is have it pass back several parameters -- accesslevel, firstname, lastname

how can i do this?

and how can i get the different values into my asp.net page?

you can define your own soap header where you deliver your requested data.

before you execute your webservice, you verify the header information and then you run into your method.

even if you dont speak german, check the code sample at the following page:http://www.aspheute.com/artikel/20030501.htm this explains it pretty simple..


You can either return a DataSet containing a DataTable with the required columns, or create a custom class that has these as fields (make sure it is serializable).

pass more than one parm

hey all,
i'm in a template column of a gridview. i have a hyperlink in the Item
Template and i'm trying to do a custom binding expression to it. So far i
have the following:

Eval("FILE_ID", "~/ViewFile.aspx?Id={0}")

Is there a way to pass more than one parm? If so, could someone please show
me the syntax?

thanks,
rodchar"rodchar" wrote:

Quote:

Originally Posted by

hey all,
i'm in a template column of a gridview. i have a hyperlink in the Item
Template and i'm trying to do a custom binding expression to it. So far i
have the following:
>
Eval("FILE_ID", "~/ViewFile.aspx?Id={0}")
>
Is there a way to pass more than one parm? If so, could someone please show
me the syntax?
>
thanks,
rodchar


rod,

Inside your binding syntax, you'll have to call another formating function
that takes multiple arguments. Try this:

<ItemTemplate>
<asp:HyperLink ID="lnkTest" runat="server"
NavigateUrl='<%# String.Format("~/Temp.aspx?id={0}&id2={1}", Eval("id1"),
Eval("id2")) %>' Text="Link 1"></asp:HyperLink>
</ItemTemplate>

If your binding is more complicated than what string.Format() can handle
then declare a function in your codebehind and call that function inside your
templated column. Something like:

inside your codebehind declare a function...

public string FormatURL(string arg1, string arg2)
{
return string.Format("~/Temp.aspx?id={0}&id1={1}", arg1, arg2);
}

<ItemTemplate>
<asp:HyperLink ID="lnkAnotherTest" runat="server"
NavigateUrl='<%# FormatURL(Eval("id1").ToString(), Eval("id2")).ToString()
%>' Text="Link 2">
</asp:HyperLink>
</ItemTemplate>

Hope this helps,
Jason Vermillion
awesome, thank you for the help. rod.

"Jason Vermillion" wrote:

Quote:

Originally Posted by

"rodchar" wrote:

Quote:

Originally Posted by

hey all,
i'm in a template column of a gridview. i have a hyperlink in the Item
Template and i'm trying to do a custom binding expression to it. So far i
have the following:

Eval("FILE_ID", "~/ViewFile.aspx?Id={0}")

Is there a way to pass more than one parm? If so, could someone please show
me the syntax?

thanks,
rodchar


>
rod,
>
Inside your binding syntax, you'll have to call another formating function
that takes multiple arguments. Try this:
>
<ItemTemplate>
<asp:HyperLink ID="lnkTest" runat="server"
NavigateUrl='<%# String.Format("~/Temp.aspx?id={0}&id2={1}", Eval("id1"),
Eval("id2")) %>' Text="Link 1"></asp:HyperLink>
</ItemTemplate>
>
If your binding is more complicated than what string.Format() can handle
then declare a function in your codebehind and call that function inside your
templated column. Something like:
>
inside your codebehind declare a function...
>
public string FormatURL(string arg1, string arg2)
{
return string.Format("~/Temp.aspx?id={0}&id1={1}", arg1, arg2);
}
>
>
<ItemTemplate>
<asp:HyperLink ID="lnkAnotherTest" runat="server"
NavigateUrl='<%# FormatURL(Eval("id1").ToString(), Eval("id2")).ToString()
%>' Text="Link 2">
</asp:HyperLink>
</ItemTemplate>
>
Hope this helps,
Jason Vermillion
>
>