473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

PostBackUrl with a variable attached?

I've been looking around for the proper syntax, and have only found one
instance where it appeared somebody else was trying the same thing, but
didn't post how they had achieved their desired result.

What I want to do is PostBackUrl="mypage.asp?myid="+txtSearch

where txtSearch is the name of my text box containing the variable i
want to pass.... I assume I need {0} or something of the sort, and have
tried many different syntax variations, but cannot seem to get this to
work properly.

Mar 16 '06 #1
6 12276
For this situation you have 2 options.

String.Format()
String.Concat()

I would use concat in this instance.

string.Concat("mypage.asp?id=", textSearch)

Here is the Format()
string.Format("mypage.aspx?id={0}", txtSearch)

HTH,
Tony
"KBuser" <Ky********@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
I've been looking around for the proper syntax, and have only found one
instance where it appeared somebody else was trying the same thing, but
didn't post how they had achieved their desired result.

What I want to do is PostBackUrl="mypage.asp?myid="+txtSearch

where txtSearch is the name of my text box containing the variable i
want to pass.... I assume I need {0} or something of the sort, and have
tried many different syntax variations, but cannot seem to get this to
work properly.

Mar 16 '06 #2
Anthony Merante wrote:
For this situation you have 2 options.

String.Format()
String.Concat()

I would use concat in this instance.

string.Concat("mypage.asp?id=", textSearch)

Here is the Format()
string.Format("mypage.aspx?id={0}", txtSearch)

HTH,
Tony

Thank you Anthony, but I'm not sure if that is what I'm looking for...
I have my button, btnSearch, and I want to put a variable into one of
its attributes, without having to do any c# or vb coding.
<asp:Button ID="btnSearch" runat="server" Text="Search"
PostBackUrl="dvd.aspx?dvd={0}",txtSearch />

This is my first ASP.NET project (I'm using visual web dev 2005), so I
apologize if I'm misunderstanding what you're saying to do....

Mar 16 '06 #3
> I have my button, btnSearch, and I want to put a variable into one of
its attributes, without having to do any c# or vb coding.
<asp:Button ID="btnSearch" runat="server" Text="Search"
PostBackUrl="dvd.aspx?dvd={0}",txtSearch />


If you have the variable txtSearch initialised *before* the page is
rendered (i.e. it is determined beforehand on the server side) then
there is no way of doing exactly what you want; just add some code to
your OnLoad event to set the required property.

If not, use Javascript or do a postback first...I doubt this is what
you want, though

Mar 16 '06 #4
> ... then there is no way of doing exactly what you
want; just add some code to
your OnLoad event to set the required property.


You could actually try <asp:Button ID="whatever" runat="server"
Text="search" PostBackUrl="dvd.aspx<%txtSearch%>">, which will cause
the parser to evaluate the expression inside the <% %> tags and insert
it.

Mar 16 '06 #5
> PostBackUrl="dvd.aspx<%txtSearch%>">

Hehe, bad typing day today. There should be an equals sign after the
first %

Mar 16 '06 #6

Paul Henderson wrote:
PostBackUrl="dvd.aspx<%txtSearch%>">


Hehe, bad typing day today. There should be an equals sign after the
first %


Thanks, I think this is close to what I want. The text box i'm reading
from is on the same page as the button, and the only reason why I don't
use the text box as the datasource for my gridview is because I need to
load this page from other pages as well (which pass a dvd id to search
for).
PostBackUrl="dvd.aspx<%=txtSearch%>">
Produces
dvd.aspx%3C%=txtSearch%%3E
at the end of my querystring, and gives an error:
The connection was reset
The connection to the server was reset while the page was loading.

Mar 16 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: osh | last post by:
All, I am having trouble using the PostBackUrl feature in .NET 2.0. I have several User Controls that are on a MasterPage. The User Controls contain the form fields for a basic search on...
0
by: wendylau81 | last post by:
We are currently using ASP.NET 2.0 to revamp one of our web applications. Let me try to briefly explain how each page is laid out... Usually within the page, there are 3 components... The...
1
by: Wendy | last post by:
I had previously posted this in inetserver.asp.components, I don't think that was the right place... anyways, here is a repost: We are currently using ASP.NET 2.0 to revamp one of our web...
0
by: Wendy | last post by:
We are currently using ASP.NET 2.0 to revamp one of our web applications. Let me try to briefly explain how each page is laid out... Usually within the page, there are 3 components... The header,...
4
by: sck10 | last post by:
Hello, Can you use the PostBackUrl to post to different sites? I have a page (PostBackURL.aspx' ) on one website (same server) that has a button set to: PostBackURL="http://zone1.web.com" ...
2
by: xeroxero | last post by:
I have the property "PostBackUrl" set on a LinkButton set to "~/page.aspx". I tried to change this value in the Page_Load as well as the Render event to a different page based on some flow/business...
1
by: Chris | last post by:
Hi, i created an ImageButton within an ItemTemplate of a datalist (in shop.aspx). There are two possibilities: 1) when the user is logged and he clicks on an image, he must be 'postbacked' to...
2
by: noneya22 | last post by:
I'm using asp.net 2.0. I have a page that has a save button and a cancel button along with a text field. All controls are asp.net server controls. I have JavaScript that prompts the user if he...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.