Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to use same code in many aspx pages without use code behind the lines

    I'm workin in a medium large intranet project with more than 40 aspx pages and I need to replicate the same variable declarations and functions in most of these pages.

    I am aware that this functionality can be fulfilled using clases and code behind the lines but I have a big restriction: by corporate network and system policies, I am not allowed to install any, and it means ANY, piece of software different from the actual server configuration. I can only work with scripts to be iterpreted by the server.

    As a result of this policy, the aspx pages are using Visual Basic code to be interpreted at the server side, vbs and javascripts at the client side and plain html witout using .net objects. Neither of the pages can use code behind the lines.

    Question is: Is there any way similar to the old "include .vb files" used with ASP pages that I can use to reuse code in aspx pages?

    Thanks for your help.

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,083
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Are you able to use master pages? If so, is the code you're talking about something that could be put in the master page?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vinyl-junkie View Post
    Are you able to use master pages? If so, is the code you're talking about something that could be put in the master page?
    Yes, I can use master pages as longer as they do not use code behind the lines.

  • #4
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vinyl-junkie View Post
    Are you able to use master pages? If so, is the code you're talking about something that could be put in the master page?
    And here it is an example of some code I need to replicate and maintain inside each page.

    Is it posible to do it with master pages without using code behind the lines?



    <%@Page Language="VB" explicit="true" %>
    <%@Import Namespace="System.Data" %>
    <%@Import Namespace="System.Data.OleDb" %>
    <%@Import Namespace="System.Net.Mail" %>
    <%@Import Namespace="System.IO" %>
    <%@Import Namespace="System" %>

    <!DOCTYPE html Public "-//W3C//DTD Xhtml 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
    '---- Connection string ----
    Protected strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\HR_LES_080508.mdb") & ";User Id=admin;Password=;"
    Protected micsSTRConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\MICS.mdb") & ";User Id=admin;Password=;"
    '---- Connection object ----
    Protected hrlesConnection As OledbConnection 'Connection Object to db
    Protected micsConnection As OleDbConnection 'Connection object to MICS DB
    '---- Connection adapter ----
    Protected dbAdapter As OleDbDataAdapter 'Command db Adapter
    Protected micsAdapter As OleDbDataAdapter 'Command mics Adapter
    '---- Connection dataset ----
    Protected dbDataSet As DataSet 'db DataSet (instead Recordset)
    Protected micsDataSet As DataSet 'mics dataset
    '---- User ----
    Protected username, serverDomain As String 'SignetID and domain
    Protected signetID As String
    Protected userID As Integer




    Function checkForFIAssistantStatus() As Boolean
    Dim dbTable As DataTable 'Data reception table
    Dim sqlSTR As String
    Dim numRows As Integer
    dbTable = New DataTable
    ' String por adapter command
    sqlSTR = " SELECT tbStatus.lesID, tbStatus.codeID, tbStatus.startDate, " _
    & "tbStatus.endDate, tbStatus.numericValue, tbStatus.stringValue " _
    & "FROM tbLes INNER JOIN tbStatus ON tbLes.ID = tbStatus.lesID " _
    & "WHERE (((tbStatus.codeID)=243) AND ((tbLes.signetID)=""" & pageUserSignetID & """)) " _
    & "ORDER BY tbStatus.endDate DESC;"

    sqlCommandAndFill(sqlSTR) 'Assign Adapter command and Data set
    dbTable = dbDataSet.Tables(0) 'Assign table
    numRows = dbTable.Rows.Count
    If numRows > 0 Then
    If dbTable.Rows(0).Item("endDate") > Now Then
    Return True
    End If
    End If
    Return False
    End Function



    'Business rules assignment procedure to hidden fields
    Sub createBusinessRulesFields()
    '1 010 Office Working Hours per Week
    Response.Write("<input name=""brOfficeWorkHoursWeekField"" id=""brOfficeWorkHoursWeekField"" " _
    & "type=""hidden"" value=""" & brOfficeWorkHoursWeek & """ />")
    '2 020 Non Office Working Hours per Week
    Response.Write("<input name=""brNonOfficeWorkHourWeekField"" id=""brNonOfficeWorkHourWeekField"" " _
    & "type=""hidden"" value=""" & brNonOfficeWorkHourWeek & """ />")
    '3 030 Office Working Hours per Day
    Response.Write("<input name=""brOfficeWorkHoursDayField"" id=""brOfficeWorkHoursDayField"" " _
    & "type=""hidden"" value=""" & brOfficeWorkHoursDay & """ />")

    End Sub

    ....... And many functions more

  • #5
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is really simple. Create a new web form in visual studio without code behind. add a button in design mode. double click the button and you will see the onclick function. change to source and you will see how it writes it all inbetween the <script> tags up top. That should help you get started. good luck.

  • #6
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Tks Websitepro.

    I have a Doubt... The new web form you are talking about, shoul it be a master page? If yes,

    How can I include it as a masterpage in my project since I have not defined a materpage right now.

    Plase be patient... as you can see I'm some kind of newbee..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •