hai,
i wish to know how to call a function from an aspx page,
i define that function in aspx.cs page,pls anyone can tell me
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Soft CornerPosted Feb 10, 2011, 6:10 AM
In your aspx page Just write this code, where u want a call
<% tablebuild(); %>
It will work and as i said above ,use a namespace in the Inherits section of Page directive (by default it will b there but in case if u got an error)
let me know if u done with this :)
Amit ChoudharyPosted Feb 10, 2011, 6:26 AM
first.aspx.page write the aspx suppose you can call it as below:
<%# tablebuild()%> or <% tablebuild()%>
Try any of this will surely execute the call to this function.
Enjoy..
krithika muthukrishnanPosted Feb 10, 2011, 6:22 AM
krithika muthukrishnanPosted Feb 10, 2011, 6:21 AM
Krishna GaradPosted Feb 10, 2011, 6:15 AM
Krishna GaradPosted Feb 10, 2011, 6:04 AM
first set page attribute EnablePageMethod=true
in your .aspx page now write any javascript function to call the function of .aspx.cs file
like
Might it helps you.
krithika muthukrishnanPosted Feb 10, 2011, 5:46 AM
hai
i write this code in first.aspx.cs page
how can i call this function from first.aspx source page.
public void tablebuild()
{
Response.Write("
string connectionstring = @"data source=System-7\sqlExpress;initial catalog=Project;User ID=sa;Password=as;";
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
string query = "select category,posts from titlename";
DataTable dt = new DataTable();
SqlDataAdapter objadapter = new SqlDataAdapter(query, con);
objadapter.Fill(dt);
int i = 0;
while (dt.Rows.Count > i)
{
Response.Write("
i = i + 1;
}
}
Thanks,
Soft CornerPosted Feb 10, 2011, 5:31 AM
you have define one function say f_MyFunction in .cs file . Now u want to acces this funct in aspx. then try this
<%=f_MyFunction()%>
use a namespace in the Inherits section of Page directive. For more information about Page directive, see http://msdn2.microsoft.com/en-us/library/ydy4x04a(VS.80).aspx
Amit ChoudharyPosted Feb 10, 2011, 5:21 AM
I dont understand what method you have wrote in aspx file. Is it server side method or Javascript function??
please elaborate more..
Thanks