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

button to only execute javascript and not postback (using code behind)

I want to create a button using code-behind that only executes javascript,
and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.

Thank you
Nov 18 '05 #1
4 2713
Joe
Hmmmm, you could check out the autopostback attribute or set the
autopostback property of your button to false if you are building it in a
codebehind.

Joe
"Marcel Balcarek" <ma*************@REM-OVEMEtoxicall.com> wrote in message
news:u1**************@tk2msftngp13.phx.gbl...
I want to create a button using code-behind that only executes javascript,
and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.

Thank you

Nov 18 '05 #2
hi,
any javascript run in the (client) onclick event of an
asp.net button will fire before any server side code, and
can prevent a postback to the server if you "return
false;" from the javascript.

alex
-----Original Message-----
I want to create a button using code-behind that only executes javascript,and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.
Thank you
.

Nov 18 '05 #3
Thanks Joe, and Alex

Unfortunately, in my VB .NET the imagebutton does not have an autopostback
property / attribute.

The following works:

1) return false from the javascript call

Me.BoldImageButton.Attributes.Add("onclick",
"javascript:FormatText('testiframe', 'bold', '');return false")

2) ensure that the form does NOT have an onsubmit, as this will execute

<form id="Form1" onsubmit="return submitForm();" method="post"
runat="server"> -->

Thank you for your help.

Marcel

"Marcel Balcarek" <ma*************@REM-OVEMEtoxicall.com> wrote in message
news:u1**************@tk2msftngp13.phx.gbl...
I want to create a button using code-behind that only executes javascript,
and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.

Thank you

Nov 18 '05 #4
Why not just make it a simple HTML input button if you
don't need to post data back?

Bin Song
MCP
-----Original Message-----
I want to create a button using code-behind that only executes javascript,and does not post back to the server.

How can I do this - my ImageButton insists on posting back to the server.
Thank you


Nov 18 '05 #5

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

Similar topics

2
by: Cathy | last post by:
Has anyone ever made a webform button run an onClick event that is a Javascript in the HTML code and then after running the script make it go into the code-behind? An HTML button will run the...
4
by: Carlo Marchesoni | last post by:
I have a button that opens a new Window (some kind of search-window), which is fired using JavaScript (btnSearch.Attributes=".....";) Now I need to run some code behind code BEFORE this JavaScript...
4
by: Jeremy | last post by:
I have an ASPX page with a bunch of System.Web.UI.WebControls.Button controls on it. By default, clicking on any of these causes a Postback. I'd like to have it so that for a couple of these...
5
by: dje | last post by:
In the OnClick event on a radioButtonList, I run a javascript to show/hide the appropriate div along with a submit button, which displays as expected. The problem is the submit no longer works on...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
6
by: shil | last post by:
I have a server side button that needs to do some preperation and afterwards, if everything goes well, open a new browser with a specific url. I know how to execute javascript from a server side...
4
by: Ryan | last post by:
Hello, I have a standard HTML button on an aspx web form that I have set to runat server. The button is named reset1 and its tag is as follows: <INPUT id="btnReset1" style="WIDTH: 60px;...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
5
by: C Watson | last post by:
Hi, I'm wondering if anyone can help me with AJAX in ASP.NET 1.1. I have a very specific feature that I would like to use it for. I have a rather long form that the users use to enter data...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.