You have to write connection String in Web.config under Configuration Section Like following:
<connectionstrings>
<add name="ConStr" connectionstring="Server=.;DataBase=test;integrated Security=true" providername="System.Data.SqlClient">
And Access the connection String in code behind like following:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString);
OR
string str=ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
Now you can use "str" as connection String any where