Put SQL and ASP code on a script instead of on my web page

crypter_1

New Member
Im designing a web site and trying some new concepts. instead of just coding everything onto a web page, i am populating different areas of the page using a database. for example on a news page, i have a drop down to select the story, then I have different areas of the page pull in the headline, story, picture and date which are all stored in the database. everything is working good. the only thing I want to do is clean up the code a little. Id like for all the connection strings and select statements to be stored in a method on a script or something. and preferably on a HTML page, not an aspx page.I have a decent amount of knowledge with basic HTML, and some experience programming with Visual Basic.net and SQL. I am using Visual studio 2012, putting all of this on an ASPX page.here is an axample of what i have written and working. this displays the headline of the story based off of the value selected in the "NewsDropDown" Drop list.\[code\] <%-- displays the headline --%> <asp:FormView ID="NewsHeadlineText" runat="server" DataSourceID="NewsHeadline" class="hdr" meta:resourcekey="NewsHeadlineTextResource1" > <ItemTemplate> &nbsp;<asp:Label ID="HeadlineLabel" runat="server" Text='<%# Bind("Headline") %>' meta:resourcekey="HeadlineLabelResource1" /> <br /> </ItemTemplate> </asp:FormView> <asp:SqlDataSource ID="NewsHeadline" runat="server" ConnectionString="<%$ ConnectionStrings:VBallTalksDBConnectionString %>" ProviderName="<%$ ConnectionStrings:VBallTalksDBConnectionString.ProviderName %>" SelectCommand="SELECT [Headline] FROM [News] WHERE ([Headline] = ?)"> <SelectParameters> <asp:ControlParameter ControlID="NewsDropDown" Name="Headline" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource>\[/code\]
 
Back
Top