Obtain the parameters set in Web. config in Asp. Net! (Front and back-end code example), asp. netweb. config
1. Set code in Web. config
<Deleetask>
<Add key = "deleted" value = "1"/> <! -- Delete a flag -->
</AppSettings>
2. Create sys. cs in App_Code
// Note: You need to add a reference namespace using.
Public class sys
{
Public static int deleted = int. Parse (ConfigurationManager. deleettings ["deleted"]);
}
Iii. calls in cs files
If (aaa = systemparam. deleted)
{
.......
}
ASPNET obtains the webconfig data connection Field
Page type:
String constr = ConfigurationManager. ConnectionStrings ["connString"]. ConnectionString
Web. config:
<ConnectionStrings>
<Add name = "connString" connectionString = "server = database address; database = database; user id = database login user; password = database login password;" providerName = "System. data. sqlClient "/>
</ConnectionStrings>
How can I call the SQL database connection configured in the webconfig of ASPNET?
First, add using System. Configration.
Use ConfigrationManager. ConnectinStrings [""]. ConnectionString. Brackets are the name in the configuration file.