J
Jon Delano
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.Attributes.Add("onclick", "CheckDictationMode();")
here is the javascript function
function CheckDictationMode() {
if (document.all('lblDictationMode').innerHTML!='') {
alert('Please finish or cancel your edit/creation of the current
dictation before selecting a new patient.');
return false;
}
else {
DisplayDataRequestMessage();
}
}
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 CheckDictationMode function using
onSubmit="return CheckDictationMode()". 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
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.Attributes.Add("onclick", "CheckDictationMode();")
here is the javascript function
function CheckDictationMode() {
if (document.all('lblDictationMode').innerHTML!='') {
alert('Please finish or cancel your edit/creation of the current
dictation before selecting a new patient.');
return false;
}
else {
DisplayDataRequestMessage();
}
}
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 CheckDictationMode function using
onSubmit="return CheckDictationMode()". 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