Solved LinkButton - DO an ajax request and then submit the form

Posted on 2009-04-04
Last Modified: 2012-06-27
Dear experts,

I have a form and to submit the form I am using a linkButton. My linkbutton also does some client side validation before submitting the form. A requiremtn has now come in that I do some server side validation before submitting the form. This means the linkbutton first needs to send an ajax request (without doing a page refresh) and based on the result give the user a modal popup. On the modal popup if the user clicks continue, i need to submit the form otherwise cancel submitting the form.

I am really stuck and have no idea if/how thsi can be achieved. Please help!
Question by:vbhargav80
  • 2
LVL 14

Assisted Solution

amar31282 earned 100 total points
ID: 24067971
you need to use javascript as
    function TestFunction(data)


        var flag = true;

        if( data == "") 


            flag = confirm("You have not entered any name. This will result in all the records.\nDo you want to Continue...");


        return flag;


In link button use

OnClientClick="return TestFunction(document.getElementById('Simple_Search_Faculty_Name_Input').value);"

Open in new window


Expert Comment

ID: 24068387
I will give you an overview of how it can be done ..

1. write a javascript function and attach it to the link button ,
2. In that function send an ajax request to the page where you have the server side validation.
    Return a value from the server page
3. On the function which process the response, compare the value from server , then open a modal dialog using showmodal dialog function
vReturnValue = window.showModalDialog()
4. now check the return value from the modal for submitting or cancel page progress


Author Comment

ID: 24069394
My LinkButotn already has some javascript attached to it which is doing the client side validation. How can I attach 2 different pieced of javascript to it, 1 that does client side and 1 that does server side?

Accepted Solution

mahadevan_v earned 400 total points
ID: 24070787
no need to add another function

after the client side validation create an ajax request to the server page

function ajaxFunction()
// DO YOUR CLIENT VALIDATIIOIN//if all your client validations are passed call the server page with validations using the below code..

var xmlHttp;
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
catch (e)
  // Internet Explorer
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  catch (e)
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    catch (e)
      alert("Your browser does not support AJAX!");
      return false;
//This statement get value from the server page and sets it to control add a client validation for checking the return value

Check this link for examples

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity bundle 8 36
jQuery aJax Disable Async 24 44
ASP.Net Session State alternatives 3 30
ASP.NET Web Form Variables being reset 2 18
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now