Calling another function in Java Script function

Hi ,

I am using input file control to get the list of files for eg Access MDB

Once user selects a file I display the path and activate a button "Click to Get List of Tables" eg btn_Access

In the button click I call a function to populate list of Access tables

Now everytime user has to click the button .

Since it is Input file control I have written a Java Script function to handle click event .

Now I need to call btn_Access click function in this Java Script function

How do I do it or is there some way to call C# function

Thanks

 

 

0
khushi2005
9/25/2007 2:05:22 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
1054 Views

Similar Articles

[PageSpeed] 5
Get it on Google Play
Get it on Apple App Store

You can use javascript to grab the button object, then use the click() method on it. That will trigger the button in the same was as a user actually clicking it, which includes triggering the click event in the code behind.

I suggest doing something like this: 

var btn = document.findByID("<%= btnAccess.clientID %>");
if (btn)
{
    btn.click();


0
EndangeredMassa
9/25/2007 2:41:05 PM

khushi2005:

I am using input file control to get the list of files for eg Access MDB

Once user selects a file I display the path and activate a button "Click to Get List of Tables" eg btn_Access

In the button click I call a function to populate list of Access tables

Now everytime user has to click the button .

Since it is Input file control I have written a Java Script function to handle click event .

Now I need to call btn_Access click function in this Java Script function

How do I do it or is there some way to call C# function

 

Hi khushi2005,

Base on my understanding, you can try to use the following way to solve your problem:

JavaScript way:

    function OnClientClick( ServerControID ){
var objDemo = document.getElementById(ServerControID);
if(objDemo){
objDemo.click();
}
    <input id="btnJavaScriptWay" type="button" value="JavaScript Way" onclick="OnClientClick('btnServerButton')" />

C# way:

btnCShapeWay.Attributes.Add("onclick", "OnClientClick('btnServerButton')"); 
And see the whole code: 
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        btnCShapeWay.Attributes.Add("onclick", "OnClientClick('btnServerButton')");
    }
    protected void btnServerButton_Click(object sender, EventArgs e)
    {
        Response.Write("Hollo, World!");
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Click Demo</title>

    <script language="javascript" type="text/ecmascript">
    function OnClientClick( ServerControID ){
        var objDemo = document.getElementById(ServerControID);
        if(objDemo){
            objDemo.click();                        
        }        
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <input id="btnJavaScriptWay" type="button" value="JavaScript Way" onclick="OnClientClick('btnServerButton')" />
        <asp:Button ID="btnCShapeWay" runat="server" Text="C# Way" />
        <asp:Button ID="btnServerButton" runat="server" Text="Itself Way" OnClick="btnServerButton_Click" />
    </form>
</body>
</html>
 

Please correct me if I have misunderstood your mean, please LET ME KNOW. Thanks,

Hope it helps,

Hong Gang



Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
9/28/2007 8:14:34 AM
Reply:

Similar Artilces:

java script function in .net function
Dear All,I’m trying to open up a window with a form in it, but first I need to make sure that the user checked at least one or more item on a list with checkboxes in each row on the page where I push the button to open the window from.I use the following simple code:Public Sub btnLog_onClick(ByVal sender As System.Object, ByVal e As System.EventArgs)           Dim myCsv = getTickedItems(1)         If myCsv = "" Then             Exit Sub  ...

how to call java script function in vb.net ?
I have working with grid view and get records from database if the records exceding 1000 then I need to display confirm dialog box through javascript ? if click ok then it will display the records in gridview and if click cancel then it will create a message into label .   want to know where to call java script function on the button that will display this javascript dialog.Basim Hi, try this... //Code to get the datasource dataset ds if(ds.Tables[0].Rows.count > 0) {     Page.ClientScript.RegisterStratUpScript(this.GetType(),"showal","ShowGri...

how to call another function in a function?
what's the syntax should be? A function call can be made from another function/method (different ppl giving it different terms) by placing the name you've given the function in your function definition.   For example in C#: public int CalculateAdd(int x, int y){ return x+y;}public void CallAboveFunction(){ int result = CalculateAdd(2, 3);}   Example in VB.NET Function CalculateAdd(ByVal x As Integer, ByVal y As Integer) As Integer CalculateAdd = x + yEnd FunctionSub CallAboveFunction() Dim result as Integer result = CalculateAdd(2, 3)End S...

Why is my function call not waiting for a callback from another function call
Why is my javascript being called prematurely and how can I fix this.  When the update happens, the JavaScript call is not waiting for the callback from the update.  So it is reloading my page prematurely before the update is done.     Protected Sub btnAccept_Click(ByVal sender As Object, ByVal e As EventArgs)           Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder("")         sb.Append(vbCrLf)         sb.Append("<script language...

How to call java script function in vb.net(aspx.vb file)
Hi, i have written following script in aspx file which works fine:  ----------------------------------------------------------------------------------<script type="text/javascript" language="javascript"> function Enable_ddlyear() {  document.form1.TxtStartDate.disabled=true ; document.form1.TxtEndDate.disabled=true ;var x=document.getElementById("ddlyear") x.disabled=false }  function Enable_dates() {document.form1.TxtStartDate.disabled=false ; document.form1.TxtEndDate.disabled=false ;document.form1.ddlyear.disabled=true ; ...

How to call another function inside a function.
 Hello,My requirement is like I am inheriting a js file in an application and I need to call the functions inside that file from another function which is also a javascript function.Here is the code//this is the styleswitch.js file  <script src="/jscript/styleswitch.js" type="text/javascript"/> in the below function i need to call a function which is there in that function<script type="text/javascript">function changestyle(){//here i need to cal the function which is in the styleswitch.js }  1) fix your link to the external...

Call function inside another function
 Hello,How do I call this function from inside another function ?? function validate(MyForm,txtEmail) {   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;   var address = document.forms[MyForm].elements[txtEmail].value;   if(reg.test(address) == false)    {      alert('invalid email');      return false;   }}Thank you One of the many ways to call the function  function OuterFunction(Myform,txtEmail){validate(Myform,txtEmail); } Jeev~~~~~~~~~~~~...

How to call AJAX function from a PowerBuilder 11.5 .NET Web Forms application?
Dear All, I would like to know if it is possible (if yes then how) to call AJAX function from a PowerBuilder 11.5 .NET Web Forms application. Any pointer or information is much appreciated. Thank you very much in advance. Thanks and Best Regards, Jessica The first thing you need to do is install the AJAX Extensions for ASP.Net. They can be downloaded here: http://www.microsoft.com/downloads/details.aspx?FamilyID=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&displaylang=en You write a client-side JavaScript event handler - say myScriptFile.js. Then, in the PowerBuilder ...

failed to call web service from java script function,error [object Object]
hi,i have java function which calls n recieve an array from webservice,everything is working in visual studio,but once i save my web pages on server n try to access it via web browser it fails to call webservice,n goes to onError function n gives this alert  "[object Object]", do i need to install anything on server rather than ajax? // WebServiceMultipleCallers.js var map; function load() {if (GBrowserIsCompatible()) {   map = new GMap2(document.getElementById("map")); map.addControl(new GMapTypeControl); map.addControl(new GLargeMapControl); map.setCenter(new GLatLng(10...

call DetailsView_ItemInserted function from another function
Hello all,I need to add data to a database using the ItemInserting function from a DetailsView (which works), but at the same time I need to update a value within another table.  I was thinking of putting a hidden seperate detailsview & datasource which would update the other table.  My problem is that I don't know the proper code to call the ItemsInserted function (the red ??? in the code below).  I know it needs two arguments object sender & DetailsViewInsertedEventArgs e, but as a novice I am not sure what those arguments are.  Any help would be greatly appreci...

How to call java script function in a web user control without using body tag
 I have a web user control which i have embedded in my default.aspx page.1. Currently i am calling two javascript methods -hello( ) and bye( )  from Web user control client side. This creates two body tags in the page when i run the default.aspx (where control is registered) and can see it in page source. which i guess is incorrect way as use control should not have any body tag... Please suggest me a way to call my java script methods in control at client side without using any tags already there in my container page (default.aspx) If this post helps you, please mark it as An...

how to call a c# function if user click on ok button of java script confirm box in .net
hi, i have one problem that is i'm adding the new user to database, if that user is already exist in the database one pop up should display with message like 'user already exists are u sure you want to update the role of the user' with 'yes' and 'no ' buttons on pop up, if user click on 'yes' button then it should call edituser() method of c3.net other wise it should reset the selected controls. how to do this using extenal .js file with javascript confirm box   Hi When user click on "Yes" set a asp.net hidden field value to be "t...

superreview granted: [Bug 319172] "function eval must be called directly, and not by way of a function of another name" in loaded sub-scripts. : [Attachment 205112] Innerize the global object
Brendan Eich <brendan@mozilla.org> has granted Brendan Eich <brendan@mozilla.org>'s request for superreview: Bug 319172: "function eval must be called directly, and not by way of a function of another name" in loaded sub-scripts. https://bugzilla.mozilla.org/show_bug.cgi?id=319172 Attachment 205112: Innerize the global object https://bugzilla.mozilla.org/attachment.cgi?id=205112&action=edit ------- Additional Comments from Brendan Eich <brendan@mozilla.org> sr=me, if you want it. /be ...

call ClientValidation Function from another javascript function
 Inorder to call the ClientValidationFunction of a asp.net validator control in another javascript function, what would I pass as the parameters for source and args?   Basically I want to do this because I want to display the validation message for a control when the submit button is pressed and also if the option that makes this field required is selected. So then the second it becomes required it will display the validation text.  I would want to call the ClientValidationFunction in the javascript code for  the on change event of several other controls.  ...

Web resources about - Calling another function in Java Script function - asp.net.web-forms

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

TV binging, exercise skipping linked to poor cognitive function
... their fit, less TV-addicted counterparts. In particular, couch potatoes had slightly lower brain processing speeds and worse executive function, ...

iPhone best tricks and functions - Business Insider
Your iPhone can do a lot more than you think.

Learning F# – Passing Parameters to Functions
One of the first issues I faced when learning F# was finding out how to specify multiple parameters to a function. While this might sound obvious ...

HPE Offers Catalog of Virtual Network Functions for Telcos
The vendor's OpenNFV Solution Portal gives carriers a single place to find a range of VNFs that are pre-tested to run on their networks.

7 Useful Technical SEO Functions For Your E-commerce Website
This article was co-authored by Mate Dyekiss, SEO Strategist at IMI. An e-commerce website can create all the technical SEO issues onecan imagine: ...

Madras HC asks police to allow Tipu’s birth anniversary function
... Station on a petition filed by Ismail, General Secretary of Thamizhaga Makkal Jananayaga Katchi, seeking grant of permission to hold the function. ...

Colorado governor: This Planned Parenthood shooting may be a function of inflammatory rhetoric from bloggers ...
Via Grabien , skip to 4:45 of the clip below for the key bit. I naively thought we were (mostly) done with “climate of hate” stupidity after ...

Surprise: Binge-Watching TV May Cause a Decline in Brain Function
With the second season of Transparent only a few days away, some bad news awaits us: According to a recent study and common sense, probably, ...

1964 Archival Footage of British Soldiers Under the Effects of LSD Losing the Ability to Properly Function ...
1964 archival footage of British soldiers being given LSD-25 while training the the field. Over time they lost their ability to properly function, ...

Resources last updated: 12/23/2015 9:07:16 PM