How to execute javascript function then Code Behind in an ASP Button

Hi Guys,
I am currently working in a web application. I have a problem with calling a js function and codebehind.
I have this asp button that when clicked, a javascript function should be called.
My javascript function is like this:
function Calculate(){
// Set Route in google map
// Store distance, lat/long in an array
Then, after the Calculate function was executed, it should execute the code behind:
protected void btn_calculate_onclick(object sender, EventArgs e)
// Pull data stored in the array created by javascript
// connect to db
// store data
But the javascript function doesn't execute.
What should i do?
Thanks in advance

Hello,
   javascript function can not executed in server side, you can tranlate javascription fuction to c# function.
 if the reply help you mark it as your answer.
 Free
Managed .NET
Word Component(Create,
Modify, Convert & Print)

Similar Messages

  • How to execute SQL Query in Code behind Using infopath 2010?

    Hi,
    I've repeatable on infopath form, and want bind it throuth code behind from SQL table. My question is that how to execute SQL Query in code behind from infopath as well as how would get Query result to bind repeatable control?
    Thanks In Advance
    Shoeb Ahmad

    Hello,
    You first need to add new SQL DB connection then you need execute connection from code behind.
    See below link to create new connection
    http://office.microsoft.com/en-in/infopath-help/add-a-data-connection-to-a-microsoft-sql-server-database-HP010092823.aspx:
    http://www.bizsupportonline.net/infopath2010/connect-infopath-2010-sql-server-2008-table.htm
    Then use below code to execute this connection:
    AdoQueryConnection conn = (AdoQueryConnection)(this.DataConnections["Data connection name"]);
    string origCommand = Select * from tablename;
    conn.Command = origCommand;
    conn.Execute();
    Finally bind your table:
    http://www.bizsupportonline.net/infopath2007/4-way-programmatically-add-row-repeating-table.htm
    http://stevemannspath.blogspot.in/2010/09/infopath-20072010-populate-repeating.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to invoke  javascript function after business action??

    How to call javascript function(such as "window.close(), window.open(...),...") in the action method(public String doBusiness(){...}) of <h:commandButton>?If not,then,is there any alternate approach to call javascript function when the bussiness action method finished??
    Thanks a lot!

    Since your business method is called after the form is submitted, and your code is running on the server, probably the only thing you can do is this:
    Create a custom component (Maybe call it the "onLoad" component) that you always render at the top of your JSP. In the regular situation it wouldn't render anything, but in the case you mention, after your busines method, you would call a method on this new component on the server that would cause it to actually render something the next time it is rendered. When rendered this time, it could then render the "onLoad" method which has your window.close() code in it. The window would then close right away.
    The key is that you are not doing any of this on the client. The form is submitted, your business logic is executed, then the next page is rendered. When the next page is rendered, your javascript could be rendered to close the window.
    If I'm offbase here, someone please say something, I'd hate to send this guy on a wild goose chase.
    Dave

  • How to execute javascript?

    hi all,
    how to execute javascript code in our objective-c, is there any api? suppose i want execute the code
    <script type="text/javascript"
    src="http://www.google.com/jsapi?key=ABQIAAAAO1slybBNbjKwDVr_bO5qxQ3Ib9Aa-xgEU0YCgCQd4sHEEyygRTJoMiR_tlaeIJegVqgl85s-kvLA"></script>
    <script type="text/javascript">
    google.load("maps", "6");
    google.load("search", "1");
    how to execute this code please help for me..
    Regards,
    Karthik

    hi,
    thanks for reply, i am somewhat understand that UIWebView used to load the webview, but i want to use the google map api Javascript for my application, how to incorporate that, also how to load a google map link,
    Regards
    Karthik

  • How to call javascript function?

    Hi,
    How to call javascript function for SAP button
    control onclick event?
    Thanks in advance.

    Hi Sundar,
      u can call java script  in design mode.
      Add this code in ur design part inside body and call the function as
    <sap:button id="a" onSelect="javascript:go();"
    Add inside body:
      <script language="javascript>
    function go(){
    alert("hai");
      </script>
    Regards,
    Vinoth.M

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • How can I call functionality of ALV Grid by event of button outside grid?

    Hello,
    How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
    Best regards,
    Josef Motl

    hi Motl,
    these are steps to create a button in ALV and trigger an event from it..
    1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
    i_callback_program = gd_repid
    i_callback_pf_status_set = 'SET_PF_STATUS'
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWALVSTATUS'.
    endform.
    You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
    2.You have to do the following to process the new button click.
    i_callback_user_command = 'USER_COMMAND'
    form user_command using i_ucomm like sy-ucomm
    is_selfield type slis_selfield.
    case i_ucomm.
    3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status.  Then look for the standard pf status. Copy this to Z range and then add your new button.
    reward points if helpful
    regards
    satesh

  • Issue with firePartialAction or how to include JavaScript Functions

    We are using the Client Action Type: firePartialAction on an element in a region of type: TABLE. When a user enters data in here and tabs away, the action fires and recalculates 2 other fields in the same region. On a object with a small number of rows, it seems to work fine. However, when you have a large number of rows (anything over 25), the page seems to hang for nearly a minute and then when it does come back, the values are sometimes not calculated properly.
    The only reason we are using firePartialAction is because the dev guide says that JavaScript is not supported by OAF. We would much rather use a client-side JavaScript function to do these simple arithemtic operations rather than do them on the server.
    My question is two-fold:
    1 - Has anyone experienced this issue and are there any other settings or coding tricks that we should be aware of.
    2 - Has anyone ever rendered a page with a custom JavaScript tag (or library)? Also, where would you add the code in JDeveloper to get a particular element to execute a particulate javascript function (ie: onchange=MCalc())?

    The firePartialAction event is not working for us, so we need to be able to at least try out javascript. We're rendering the page from an XML file, so it's not clear to us how we would even get a custom HTML tag to render into the page at all. Normally, I'd use some kind of HttpServletResponse.getWriter()...println method call to write html (as in a controller servlet), but how would you do that using the OAWebBean? I checked the OAFromattedTextBean, would that allow me to embed onchange into the field?

  • How to execute a function and return the result into a bind variable

    Hi,
    I am trying to calculate the sum of salaries of all persons with a particular JOB_ID using a function TOTAL_INCOME(v_job_id).
    create or replace function total_income
    +(v_job_id IN varchar2)+
    RETURN number IS
    v_total number(6);
    cursor get_sal is
    select salary from employees
    where job_id = v_job_id;
    BEGIN
    v_total := 0;
    for emp in get_sal
    loop
    v_total := v_total emp.salary;+
    end loop;
    dbms_output.put_line('Total salary of '||v_job_id||' is: '|| v_total);
    return v_total;
    END;
    Now I woud like to execute this function and assign the returned value into a bind variable test_sal
    variable test_sal number(6)
    SELECT total_income('AD_VP') into :test_sal FROM DUAL;
    dbms_output.put_line('Total Sal:'||:test_sal);
    This is returning the below errors:
    SELECT total_income('AD_VP') into :test_sal FROM DUAL
    *+
    Error at line 0
    ORA-01036: illegal variable name/number
    dbms_output.put_line('Total Sal:'||:test_sal);
    Error at line 3
    ORA-00900: invalid SQL statement
    Could someone help me what could be the problem?? Thanks for your time...

    Dear,
    If everything you will do will be done inside PL/SQL (stored procedure or stored function) then you don't have to care about bind variable.
    When using PL/SQL (static SQL) you will never encounter issues related to bind variables. PL/SQL itself takes care of your code and uses bind variables behind the scene.
    The only situation where you have to look carefully to the use of bind variables within PL/SQL is when you use Dynamic sql into stored procedures or functions.
    So, see in the light of the above comment, if you have to care about returning your function into a bind variable?
    Best regards
    Mohamed Houri

  • How to execute the functionality of button at a time of pressing if function is in continuous loop?

    Hello,
    I am facing one basic problem that how can I execute the button which I have used in my vi at a time of pressing means in my vi I have used 4 button 1. Start 2. OK 3. Save and 4. Stop button
    when user press start button then continuous loop will be executed and after pressing OK it will stop that loop and waiting for next instruction from user whether he want to do reading operation again or he want to save or he want to stop.
    The thing is when I press start button then while loop is execute then its not possible to press stop button or save button, user need to wait until OK button is pressed.
    Will you please guide me how can I do so that when ever user press any button that button is executed at time.
    Thank you very much once again.
    Attachments:
    voltageforcecapacitance without instrument.vi ‏40 KB

    Hi Ankit,
    There are some issue in your code mention below please have a look and correct these will work fine for your requirement.
    1. Save button Boolean value pass to the lower wheel conditional loop means if you press save your bottom loop will stop working this is not the code requirement you have to continue loop and tigger start event in last using value tigger event property to tigger again start event.
           This step will reset your loop and start from zero.
    2. According to me I think both loop should stop only in stop condition so you can remove stop function from upper loop and pass the button value in both loop directly to wheel loop condition terminal.
           Upper loop direct and lower both loop local variable.
    3. Why you want to stop your upper loop on any error condition, you should Handel the errors and keep running the code.
    4. What is the use of queue no case related with dequeue in bottom loop.
    5. Wheel loop in a event is not  good practice so you can use your queue structure here to run continuous lower code.
    I hope these changes can improve your code.
    Thanks and Regards
    Himanshu Goyal | LabVIEW Engineer- Power System Automation
    Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
    It Only gets BETTER!!!

  • How to call javascript function & action method on clicking jsf  button?

    I have one jsf custom button. I am checking client side validations in mail by calling javascript function & also sending mail by calling action method of a bean which will execute at server side for onclick event of that button. Because of this when I click on that button its calling both javascript function and action method. So even though validations failed its sending mail. How can I overcome this problem?? Please help me....

    I am asking regarding commanLinks in jsf. I have the following code block in jsf. Even though mailSentMessage('true'); returns false, its calling action="#{emailObjectAction.sendEmail}" method. thats why I got that doubt. try the following code.
    <h:commandLink id="mailBtn123Send"      onclick="return mailSentMessage('true');" value="send mail"     action="#{emailObjectAction.sendEmail}">          
    </h:commandLink>

  • How to return javascript function value to jsp page

    Hi i want to retrieve values from javascript function to jsp page, how can i do that ? i am trying this but its not working
    <script language="javascript" type="text/javascript" src="/feedback/common/scripts/config.js"></script>
    <script language="javascript" type="text/javascript" src="/feedback/common/scripts/richtext.js"></script>
    <td>
    <jsp:param id="description" value= "<%=request.initRTE('', '')%>"/>
    </td>
    here this initRTE function is used for displaying rich text editor .....i want to retrieve back the contetnt written in this editor and save it to DB.
    Please help.
    Edited by: xtech on Apr 4, 2008 12:00 PM

    surely i will do that but my app is still not working.....
    here is my code
    </td>
    <td align="left">
    <script language="javascript" type="text/javascript" src="/feedback/common/scripts/config.js"></script>
    <script language="javascript" type="text/javascript" src="/feedback/common/scripts/richtext.js"></script>
    <h:inputHidden id="introtext" value= "<%=request.getParameterValues(description)%>">
    <script>
    initRTE('','');
    </script>
    </td>
    in java script function i am geeting the text content
    function initRTE(rtePreloadContent, rteCSS) {
    rtePreloadContent=document.getElementById('surveyinfo:introtext').value;
    startRTE(rtePreloadContent);
    menuBuilder();
    var description= document.getElementById(rteFormName).value;
    return description;
    basically i want to get the text written in text editor in jsp and want to send it to DB.(Here initRTE() function is calling rich text editor)
    i have downloaded this editor from this url
    http://freerichtexteditor.com/page/4.htm
    and trying to embed it in my app.

  • Labels pointing to pie slices with lines (or how 2 set chart properties in code behind)

    I want to be able to create lines outside of my pie chart with labels and have those lines drawn to connect to the pie chart.  I saw that this can be done in code behind in the following thread:
    MSDN thread on lines to pie slices
    But my problem is I never declared an instance of my chart when I am using my code behind.  My code that makes the reports visible is basically (but not completely) the following:
    ReportDataSet.Tables.Add(ReportDataTable)
    ReportViewer.Visible = True
    Dim ReportDataSource As ReportDataSource = New ReportDataSource("ReportDataSource", ReportDataSet.Tables(0))
    ReportViewer.LocalReport.ReportPath = ReportToDisplay.RDLCFileName
    ReportViewer.LocalReport.DataSources.Clear()
    ReportViewer.LocalReport.DataSources.Add(ReportDataSource)
    ReportDataSource.Name = ReportToDisplay.DataSetName
    ReportViewer.DataBind()
    ReportViewer.LocalReport.Refresh()
    ReportViewer.ShowReportBody = True
    ReportViewer.Width = RVWidth
    ReportViewer.Height = RVHeight
    So how do I set chart properties for my report given the above code?  As long as I can set my chart properties with the above code, I should be able to get this to work given the above thread and the link to the Label-Outside-of-Pie and Line-Color properties
    (or whatever) info on Microsoft's info page

    Hello,
    Based on your description, you want to design a
    pie chart with outside lables and pie line inside a .rdlc report. If so, you can add the Chart report item into the report after open a client report definition (.rdlc) file in graphical design mode. And then Set the
    PieLabelStyle property and PieLineColor property. Please refer to the following screen shot:
    The link your post above it about the
    Chart Web server control. As pre my undersntand, you cannot reference a Web server control inside .rdlc file.
    If you have any question about using Chart Web server control, you can post a question on
    Chart Controls for .NET Framework forum.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • How to reference JavaScript functions stored in a script object on a different page?

    Hi,
    I have a form which has 2 pages. I have a bunch of JavaScript functions under script objects on page 1. How can I access these functions from page 2?
    I tried the following but none of it work:
    form1.page2.#variables[0].testScript.doThisNow();
    form1.page2.variables[0].testScript.doThisNow();
    form1.page2.variables.testScript.doThisNow();
    Please help.

    Hi,
    Simplest way would be to drag the script object to be under the root node (form1). On both pages would would then be able to reference the function by:
    testScript.doThisNow();
    If you leave the script object under page1, then from page2, the following should work:
    page1.testScript.doThisNow();
    Hope that helps,
    Niall

  • How to put javascript function to AIR

    Hi,
    first I had Flex web application with onet javascript function in index.html file. Now I copied my code from web project mxml file to AIR project and it working properly. How can add this javascript function now. There is no html file now...
    EDIT: I am trying to do (in my AIR application) copy to clipboard using roll Over the button. Maybe I can do this in another way instead of javascript function (as i did in my web application).

    SET CLIPBOARD DATA:
    import flash.desktop.Clipboard;
    import flash.desktop.ClipboardFormats;
    var textToCopy:String = "Copy to clipboard.";
    Clipboard.generalClipboard.clear();
    Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, textToCopy, false);
    GET CLIPBOARD DATA:
    import flash.desktop.Clipboard;
    import flash.desktop.ClipboardFormats;
    if(Clipboard.generalClipboard.hasFormat(ClipboardFormats.TEXT_FORMAT)){
        var text:String = Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT);
    (From LiveDocs: http://livedocs.adobe.com/flex/3/html/help.html?content=CopyAndPaste_1.html)

Maybe you are looking for