Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a VB method in codebehind from javascript within the same form

Status
Not open for further replies.

misman2973

Technical User
Jul 1, 2003
5
US
Hello everyone,
I have the following javascript function in the head of my frmEntry.aspx page:

WHen the "insert" button is clicked:

<input id="btnInsert" type="button" value="Insert" onmouseover="ChangeButton(this);" onmouseout="ChangeButton(this);" onclick="CheckFields();"/>


function CheckFields(){
if(document.frmdocumententry.txtauthor.value==""){
alert("You must enter an Author!"); document.frmdocumententry.txtauthor.focus();
}else{
if(document.frmdocumententry.cmbDept.value==""){
alert("You must select a Department Number!"); document.frmdocumententry.cmbDept.focus();
}else{
//document.frmdocumententry.DoSave('C');
document.frmdocumententry.action="frmConfirm.aspx?CRUD=C";
document.frmdocumententry.submit();
}
}
}


This function is called and does some stuff before the form is submitted to my confirm page that has a case statement for each scenario. I've put the case operation into a "public sub CRUD" in the codebehind of the frmEntry.aspx form.

Public Sub CRUD()
Dim objError As Exception = Nothing
mf.RW(Request.QueryString("C"))
Select Case Request.QueryString("CRUD")
Case "C"....................

Here's the question:

On the following line of my "CheckFields()":

document.frmdocumententry.action="frmConfirm.aspx?CRUD=C";


I want to call the "public sub CRUD" method in the codebehind and specifically state what operation(C, R, U, D etc) Im calling within that method

document.frmdocumententry.action="frmEntry.aspx?Action CRUD(CRUD=C");???????????????????????????????????????

Any recs would be greatly appreciaited.
Thanks in advance.
S
 
S: on first glance I don't see how you can carry this out client side; you'll have to return to the server to process the codebehind. I would try and capture the Sub after returning to the server. Do a search here at Tek-Tips and see what you can find using "codebehind" + "javascript". There are a few dozen I have seen come up from time to time and one or two may have an insight to help guide you on this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top