473,408 Members | 1,754 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,408 software developers and data experts.

How to Change PostBackUrl from Client

I want to postback to the Search.aspx from default.aspx.

I have a textbox and a button on default.aspx

I want the postbackurl to be Search.aspx?q={textbox.text}
How to achieve this?

Any hacks?

I am currently doing a self-post back + redirect.

--
---------------------
Thanks
Rajiv Das
Feb 21 '07 #1
3 4591
Hi,

Rajiv Das wrote:
I want to postback to the Search.aspx from default.aspx.

I have a textbox and a button on default.aspx

I want the postbackurl to be Search.aspx?q={textbox.text}
How to achieve this?

Any hacks?

I am currently doing a self-post back + redirect.
You can access the ACTION attribute of the form using JavaScript.

<form id="myForm" action="Search.aspx" onsubmit="return setAction();">
<input id="textbox" />
<input type="submit" value="Submit" />
</form>

<script type="text/javascript">

function setAction()
{
var myForm = document.getElementById( "myForm" );
var myText = document.getElementById( "textbox" );

if ( myForm
&& myForm.action
&& myText
&& myText.value != null )
{
myForm.action = "Search.aspx?q=" + myText.value;
}
return true;
}

</script>

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 21 '07 #2
That should work, but doesn't smell like asp.net 2.0 [:)]
nonethe less, thanks.another hack I found

Button1.PostBackUrl = "javascript:SayHello()";
function SayHello()
{
location.href = "default2.aspx?q=" +
document.getElementById("TextBox1").value;
}
--
---------------------
Thanks
Rajiv Das
"Laurent Bugnion [MVP]" wrote:
Hi,

Rajiv Das wrote:
I want to postback to the Search.aspx from default.aspx.

I have a textbox and a button on default.aspx

I want the postbackurl to be Search.aspx?q={textbox.text}
How to achieve this?

Any hacks?

I am currently doing a self-post back + redirect.

You can access the ACTION attribute of the form using JavaScript.

<form id="myForm" action="Search.aspx" onsubmit="return setAction();">
<input id="textbox" />
<input type="submit" value="Submit" />
</form>

<script type="text/javascript">

function setAction()
{
var myForm = document.getElementById( "myForm" );
var myText = document.getElementById( "textbox" );

if ( myForm
&& myForm.action
&& myText
&& myText.value != null )
{
myForm.action = "Search.aspx?q=" + myText.value;
}
return true;
}

</script>

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 21 '07 #3
Hi,

Rajiv Das wrote:
That should work, but doesn't smell like asp.net 2.0 [:)]
JavaScript works on ASP.NET 2.0 just like I works on normal HTML. I
don't quite understand the comment...
nonethe less, thanks.another hack I found

Button1.PostBackUrl = "javascript:SayHello()";
function SayHello()
{
location.href = "default2.aspx?q=" +
document.getElementById("TextBox1").value;
}
That's not a POST, it's a GET. Additionally, you don't want to use the
javascript: pseudo protocol, it's known to cause problems. Don't want to
tell you what this smells like...

Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 21 '07 #4

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

Similar topics

0
by: imakowski | last post by:
I have WinForms controls hosted in the Internet Explorer (No Touch Deployment methodology). After installation of VS2005 and Framework 2.0 my deployed version of application try to use framework...
2
by: David Knaack | last post by:
Howdy I'm new to working with DB2 Universal, so I'm not very familiar with the tools. I usually only use the Java Control Center and Configuration Assistant. I have several clients on the...
3
by: Guadala Harry | last post by:
I hope this is something I can solve without contacting the vendor: I'm implementing a 3rd party component that will, by itself, initiate a PostBack. Apparently it does not support the...
12
by: marcwentink | last post by:
Can you change the appearance of a radiobutton or checkbox? I do not mean the apearance changes from checked to not checked or disabled or not disabled, but change the appearance (of all these...
0
by: sastwhc | last post by:
sastwhc wrote: > *Hi all > I try change language client side programatically.In my case farsi a > Right to Left Language,the curser direction changed by dir=rtl TAG > changed to correct direction...
3
by: peesz | last post by:
After upgrade ODBC Client from version 7.2 to 8.1 (FixPack 10) a have problem with tables where primary key is set to timestamp filed. In version 7.2 TIMESTAMP was mapped in MS Access as...
0
by: laredotornado | last post by:
Hi, I have both MySQL 5 client and server running on a Linux Fedora Core 5 machine (x86 Desktop PC). Regarding hte client, what can I do to change the default socket location? Right now, I'm...
4
by: =?Utf-8?B?RGFuaWVs?= | last post by:
Hi, How could I change a WCF client endpoint address programatically? The client is generated by Visual Studio. The purpose of doing this is to use different service address under different...
6
by: Andrew Jocelyn | last post by:
Hi How do I programmatically change (read/write) the values in this app.config file at runtime? Specifically I want to change the client endpoint address but it would be nice to change other...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.