0

I want to call function through javascript, but I get an error message "CS0103: The name 'bidindex' does not exist in the current context" Can you help me? Thanks

JS code

<script>
    function senddata(whatdate, bidindex) {          
        var a = "<%=DatabidGridView1(bidindex,whatdate%>";
    }
</script>

.cs code

public string DatabidGridView1(string sindex, string sdate)
        {
   return "good";
        }
1

1 Answer 1

1

Like homungus said the Method in your codebehind has to be a static WebMethod.

It could be something like:

JS Code

$(".clickMe").click(function(){ senddata(data, index) });

function senddata(whatdate, bidindex) {          
   PageMethods.DatabidGridView1(bidindex, whatdate);
}

.CS Code

[WebMethod]
public string DatabidGridView1(string sindex, string sdate)
{return "good";}

Also meby a useful link with useful information: Pagemethods in asp.net

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.