Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have Class1.cs class file in App_Code folder. Now i am in a situation that i have to send sql query in this class on load of the Defalt.aspx page.. i have a variable named query1 in Class1.cs file.. how to send query in class file... so that i can use that query in cs file... help will be appreciated...
Posted
Comments
Thanks7872 3-Oct-13 6:39am    
Take query in string and call method inside class file with that string as parameter.
Harpreet_125 3-Oct-13 6:43am    
sorry.. any idea of doing that??

As per my understanding. You can directly call your Class1 name in Default.aspx.cs and can use all functions of Class1. But there is no clarity with your question "send sql query in this class on load of the Default.aspx"
 
Share this answer
 
Comments
Harpreet_125 3-Oct-13 6:53am    
actually i want to use query string of default.aspx page in Class1.cs.. i am not able to do that.. because Class file is not accepting Request.QueryString["category"]. so i am thinking that how to retreive querystring of default page in Class file...
Declare Query variable as Static like public Static strQuery="...." ;

in your class1.cs page and call this variable in default page like class1.strQuer .
 
Share this answer
 
Comments
Harpreet_125 3-Oct-13 6:58am    
but i have to call variable in a class file...
suppose you need to send query in class like

string query="Sql Query";

you need to send this query to class variable query1 do as below

make object of class like


Class1 clas=new Class1();

then assing your value

clas.query1="Sql Query or reference Variable"
 
Share this answer
 
Comments
Harpreet_125 3-Oct-13 7:02am    
i am doing like that but query variable of class is not accessible on aspx page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900