473,786 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stopping the Server Side code from running ?

Hi

I was wondering if it were possible to somehow stop a page from posting back
to the server and running the server side code.
I have a datagrid and the first column is basically a button.

I have added a javascript function to the button :

Dim btnView As LinkButton = e.Item.Cells(0) .Controls(0)
btnView.Attribu tes.Add("onclic k", "CheckDictation Mode();")

here is the javascript function

function CheckDictationM ode() {
if (document.all(' lblDictationMod e').innerHTML!= '') {
alert('Please finish or cancel your edit/creation of the current
dictation before selecting a new patient.');
return false;
}
else {
DisplayDataRequ estMessage();
}
}

In the javascript function, I check the contents of a hidden field, if the
field doesn't have what I like then I display a message to the user and I
don't want the codebehind code to run (there is server side code that is
executed when the grid is clicked)

Currently I do get the message, but the form still gets submitted to the
server.

I found a bunch of stuff about simply returning false. I tried having the
onSubmit event of the form run the CheckDictationM ode function using
onSubmit="retur n CheckDictationM ode()". That never even seemed to fire at
all as I never received the message.

This is a Visual Studio 2003 web application using vb.net.
Also, this application is an inhouse deal, and only runs in IE .. so if
there is a VBScript alternative. I am all ears.

Any help would be greatly appreciated !!!!!

Thanks
Jon
May 19 '06 #1
3 1935
This is "pseudocode " but the pattern would be something like this:

function CheckDictationM ode()
{
if (confirm(...)) __doPostBack(.. .);
}

Dim btnView As LinkButton = e.Item.Cells(0) .Controls(0)
btnView.Attribu tes.Add("onclic k", "CheckDictation Mode();")
-- if the confim(which shows your message) returns false, the __doPostBack
is not called.

You'll have to experiment a bit, but that pattern should do it. You may have
disable the autopostback on the control, since you'll be deciding whether it
posts back or not now.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jon Delano" wrote:
Hi

I was wondering if it were possible to somehow stop a page from posting back
to the server and running the server side code.
I have a datagrid and the first column is basically a button.

I have added a javascript function to the button :

Dim btnView As LinkButton = e.Item.Cells(0) .Controls(0)
btnView.Attribu tes.Add("onclic k", "CheckDictation Mode();")

here is the javascript function

function CheckDictationM ode() {
if (document.all(' lblDictationMod e').innerHTML!= '') {
alert('Please finish or cancel your edit/creation of the current
dictation before selecting a new patient.');
return false;
}
else {
DisplayDataRequ estMessage();
}
}

In the javascript function, I check the contents of a hidden field, if the
field doesn't have what I like then I display a message to the user and I
don't want the codebehind code to run (there is server side code that is
executed when the grid is clicked)

Currently I do get the message, but the form still gets submitted to the
server.

I found a bunch of stuff about simply returning false. I tried having the
onSubmit event of the form run the CheckDictationM ode function using
onSubmit="retur n CheckDictationM ode()". That never even seemed to fire at
all as I never received the message.

This is a Visual Studio 2003 web application using vb.net.
Also, this application is an inhouse deal, and only runs in IE .. so if
there is a VBScript alternative. I am all ears.

Any help would be greatly appreciated !!!!!

Thanks
Jon

May 19 '06 #2
Peter

Thanks for the quick response !!
Very interesting approach..... I am using a 3rd party control called
ScrollingGrid 1.1 (Interscape Technologies) I like it a lot.
When I mouse over the linkbuttons in my first coloumn I see each row is
"javascript:__d oPostBack(gridn ame_row_col,'') " calls.

So I am thinking it is already overriding the __doPostBack functionality.
I am emailing them to ask if there is away I can override the call of each
row to my own function that I can then make the decision on whether to
display my message or postback as normal.

Thanks again for the great lead.
Jon

(cool site you have there too)

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:82******** *************** ***********@mic rosoft.com...
This is "pseudocode " but the pattern would be something like this:

function CheckDictationM ode()
{
if (confirm(...)) __doPostBack(.. .);
}

Dim btnView As LinkButton = e.Item.Cells(0) .Controls(0)
btnView.Attribu tes.Add("onclic k", "CheckDictation Mode();")
-- if the confim(which shows your message) returns false, the __doPostBack
is not called.

You'll have to experiment a bit, but that pattern should do it. You may
have
disable the autopostback on the control, since you'll be deciding whether
it
posts back or not now.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jon Delano" wrote:
Hi

I was wondering if it were possible to somehow stop a page from posting
back
to the server and running the server side code.
I have a datagrid and the first column is basically a button.

I have added a javascript function to the button :

Dim btnView As LinkButton = e.Item.Cells(0) .Controls(0)
btnView.Attribu tes.Add("onclic k", "CheckDictation Mode();")

here is the javascript function

function CheckDictationM ode() {
if (document.all(' lblDictationMod e').innerHTML!= '') {
alert('Please finish or cancel your edit/creation of the current
dictation before selecting a new patient.');
return false;
}
else {
DisplayDataRequ estMessage();
}
}

In the javascript function, I check the contents of a hidden field, if
the
field doesn't have what I like then I display a message to the user and I
don't want the codebehind code to run (there is server side code that is
executed when the grid is clicked)

Currently I do get the message, but the form still gets submitted to the
server.

I found a bunch of stuff about simply returning false. I tried having the
onSubmit event of the form run the CheckDictationM ode function using
onSubmit="retur n CheckDictationM ode()". That never even seemed to fire at
all as I never received the message.

This is a Visual Studio 2003 web application using vb.net.
Also, this application is an inhouse deal, and only runs in IE .. so if
there is a VBScript alternative. I am all ears.

Any help would be greatly appreciated !!!!!

Thanks
Jon

May 19 '06 #3
Peter

With you great lead .. here is what I came up with (with some help from a
post in a newsgroup)
AND.. it works (which is always a plus)

var oldPostBack
function window.onload() {
oldPostBack=__d oPostBack;
__doPostBack=My PostBack;
}

function MyPostBack(Para m1, Param2) {
if (document.all(' lblDictationMod e').innerHTML!= '') {
alert('Please finish or cancel your edit/creation of the current
dictation before selecting a new patient.');
document.all('l blUserMessage') .innerHTML=''; }
else {
if (typeof(oldPost Back)=='functio n') oldPostBack(Par am1,
Param2); } }

Now my site displays the message and doesn't post so everything stays right
where it was and allows the user to click the save button if they whish,
else it acts normally.

This is a better solution, as it doesn't matter what control caused the
postback. I will catch it, before I was just working on the datagrid
(scrollinggrid) .

Thanks again, I would have never thought of that __doPostBack function. You
da MAN !!!

Jon
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:82******** *************** ***********@mic rosoft.com...
This is "pseudocode " but the pattern would be something like this:

function CheckDictationM ode()
{
if (confirm(...)) __doPostBack(.. .);
}

Dim btnView As LinkButton = e.Item.Cells(0) .Controls(0)
btnView.Attribu tes.Add("onclic k", "CheckDictation Mode();")
-- if the confim(which shows your message) returns false, the __doPostBack
is not called.

You'll have to experiment a bit, but that pattern should do it. You may
have
disable the autopostback on the control, since you'll be deciding whether
it
posts back or not now.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jon Delano" wrote:
Hi

I was wondering if it were possible to somehow stop a page from posting
back
to the server and running the server side code.
I have a datagrid and the first column is basically a button.

I have added a javascript function to the button :

Dim btnView As LinkButton = e.Item.Cells(0) .Controls(0)
btnView.Attribu tes.Add("onclic k", "CheckDictation Mode();")

here is the javascript function

function CheckDictationM ode() {
if (document.all(' lblDictationMod e').innerHTML!= '') {
alert('Please finish or cancel your edit/creation of the current
dictation before selecting a new patient.');
return false;
}
else {
DisplayDataRequ estMessage();
}
}

In the javascript function, I check the contents of a hidden field, if
the
field doesn't have what I like then I display a message to the user and I
don't want the codebehind code to run (there is server side code that is
executed when the grid is clicked)

Currently I do get the message, but the form still gets submitted to the
server.

I found a bunch of stuff about simply returning false. I tried having the
onSubmit event of the form run the CheckDictationM ode function using
onSubmit="retur n CheckDictationM ode()". That never even seemed to fire at
all as I never received the message.

This is a Visual Studio 2003 web application using vb.net.
Also, this application is an inhouse deal, and only runs in IE .. so if
there is a VBScript alternative. I am all ears.

Any help would be greatly appreciated !!!!!

Thanks
Jon

May 19 '06 #4

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

Similar topics

4
6007
by: Steve Meier | last post by:
Environment: SQLServer Developer Edition on Machine A Enterprise Manager running on remote machine B Both machines are in the same subnet I open Enterprise Mgr on Machine A, right click on the Stored Proc, enter the parameters and the debugger stops on the first line and I can single
9
2230
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see) in page_load, or elsewhere, that says page.validate, no control says "causesvalidation=true", and the AutoEventWireup is set to false. So I would think that the control's server event function would NOT execute, but it does execute right after...
5
3596
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact that for server control component , code is running on the server side. But if I take as example a Label. I place on a webform an HTM label control and a WebForm label control, I could see that properties are different for
4
2513
by: Kash | last post by:
Hi everybody: I've developed a web application running on a 2003 server not on the web but on extranet environment of a small Firm (less than 10 users). I've taken benefit of Office Primary Interop Assemblies (PIAs) for automating Word on the server and everything runs smoothly on the server console. The word documents are generated perfectly from all clients and stored on the server with some data comes from a SQL server and/or stores...
3
3041
by: Paul | last post by:
Hi all, I've been trying unsuccessfully to stop client side event validation. I've created a simple page with a text box, a required field validator and a server button with the following settings: 1. <pages enableEventValidation="false"in web.config 2. EnableClientScript="false" in the required field validator. 3. EnableEventValidation="false" in the Page directive (which, I know, is not necessary).
2
6968
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
2679
by: moondaddy | last post by:
I had to repost this because I had to update and change my msdn alias. I will re-ask the question and clarify a few things that were not clear before. This code is all executed on my dev machine running winXP sp2 and VS2005. I'm using a c# 2.0 winforms app which talks to a c#2.0 asp.net app that also contains 1 web service. Note: the webpage and web service are located side by side in the same web app.
2
3371
by: Steve | last post by:
Hi All, I've been trying to come up with a good way to run a certain process at a timed interval (say every 5 mins) using the SLEEP command and a semaphore flag. The basic thread loop was always sitting in the sleep command and not able to be interrupted. When the time came to set the semaphore flag to false (stopping the thread), my program would have to wait up to the entire sleep time to break out of the loop. I have finally found...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.