Reputation: 3376
How to read the app key serviceRefPath key in my web.config
<appSettings>
<add key="serviceRefPath" value="http://localhost/TempWS/MachineHistoryWS.asmx"/>
</appSettings>
into my .aspx page
<asp:ScriptManager ID="sm" runat="server">
<Services>
<asp:ServiceReference Path="serviceRefPath here" />
</Services>
</asp:ScriptManager>
Is it possible to access the key? Thank you in advance.
Upvotes: 1
Views: 1380
Reputation: 32390
I learnt recently that you can declare you ASP.net control entirely from the code-behind page so you don't have to worry about the string literals at all.
Simply create an ASP panel where you want the control to go. Create your ASP.net control in codebehind. Finally, at the end of the code to generate your ASP.net control, put myPanel.Controls.Add(myControl)
.
Upvotes: 1
Reputation: 2039
You can do it in code-behind file:
sm.Services.Add(new ServiceReference(ConfigurationSettings.AppSettings["serviceRefPath"]));
Upvotes: 1