Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 14th, 2006, 07:53 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default Image web server control

Hi,
I have an aspx page.It has a form and a page load sub.
in the form I have:
 <asp:image id="img1" runat="server" />

Now in the page load event I want to access the imageURL and width and height properties programatically.
what should I do?
I write this but it does not work
img1.width="100"
    img1.imageURL="http://wwww.d.com"

 
Old January 14th, 2006, 08:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you define "but it does not work"? Do you get an error?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 14th, 2006, 09:57 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get this error
 System.NullReferenceException: Object reference not set to an instance of an object.

 
Old January 14th, 2006, 09:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

In that case, can you post the code for the page?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 14th, 2006, 10:54 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the code:
I get this error:
 Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Unit'
<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ import namespace="system.web.ui" %>
<script runat="server">
sub page_load(sender as object,e as eventargs)

img1.width="3"
'img1.imageURL="http://www.d.com"
end sub
</script>
<html>
 <body>


 <form runat=server>

 <asp:image id="img1" runat="server" />
 </form>

 </body>
 </html>


 
Old January 14th, 2006, 11:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

That's a different error than the one you posted earlier, and an error that can be fixed by looking at the Width property of the WebControl class in the MSDN documentation (your best friend for these kind of questions):

http://msdn.microsoft.com/library/de...widthtopic.asp

The Width is not a simple string, but a Unit. So, instead of assigning something like "100", give it a unit, like this: new Unit(100)

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 14th, 2006, 12:11 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default



<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Oledb" %>
<%@ import Namespace="System.web.UI.Webcontrols" %>
<%@ import Namespace="System.Web.UI" %>
<%@ OutputCache Duration="30" VaryByParam="CatID"%>

<script runat="server">
'++++++++++++++++++++++++++++++++++++++++++++
  'Handle page load event
  Public intWidth as integer
  Public intHeight as integer
  Public intPageSize1 as integer
  Public ImgFolder as string
  Public img1 as System.Web.UI.WebControls.Image

  Function fixBirthDate(sItem) as String
if sItem is System.DBNull.Value Then
    fixBirthDate="test"
else
    fixBirthDate=sItem
End If
End function


  Sub Page_Load(Sender As Object, E As EventArgs)

       'img1.width=New Unit(100, UnitType.Pixel)
    img1.imageURL="http://localhost/winxp.gif"
    'img1.visible="True"

    strSQL = "SELECT * from setting"
    Dim objDataReader as OledbDataReader
    objConnection = New OledbConnection(strConnection)
    objCommand = New OledbCommand(strSQL, objConnection)
    objConnection.Open()
    objDataReader = objCommand.ExecuteReader()


While objDataReader.Read()
  intWidth= objDataReader("imageWidth")
  intHeight= objDataReader("imageHeight")
  intPageSize1=objDataReader("pagesize")
  strCharSet=objDataReader("charset")
  ImgFolder=objDataReader("imageFolder")

  strBgColor=objDataReader("BgColor")
  strLinksColor=objDataReader("LinksColor")
  strHLinksColor=objDataReader("HLinksColor")
  strVLinksColor=objDataReader("VLinksColor")
  strScroll=objDataReader("scrollbar")
  strTextFont=objDataReader("textFont")
 End While

                 objDataReader.Close()

         'Call newest links
         Newest_Links()

         Most_Popular_Links()

         Sort_Category_Links()

         Display_Letter_Links()

         Choose_Category_Menu()

         Get_Cat_Name()


         Check_OrderBy_AscDesc()

         LinkAndLabel_TextDisplay()



         'Check if not postback, set the page size to 10 records per page and bind and display data
         If Not Page.IsPostBack Then

            intPageSize.text = intPageSize1
            intCIndex.text = "0"

            BindList()

         End If

  End Sub
'++++++++++++++++++++++++++++++++++++++++++++

Public Sub setting()


 End Sub


'++++++++++++++++++++++++++++++++++++++++++++

'Page level error handling - If the page encounter an error, redirect to the custom error page
  ' Protected Overrides Sub OnError(ByVal e As System.EventArgs)

   ' Server.Transfer("error.aspx")

 ' End Sub
'++++++++++++++++++++++++++++++++++++++++++++


'+++++++++++++++++++++++++++++++++++++++++++++++
'Display the alphabetical letter listing depending what tab has been view
  Sub Display_Letter_Links()

     iTabnumber = request("tab")
     Dim i as Integer
     Dim cid as integer = request("subid")
     Dim cat as integer = request("catid")
     Dim isid as integer = request("sid")

 Select Case iTabnumber

   Case "1"

      lblalphaletter.Text = string.empty
      for i = 65 to 90
  lblalphaletter.text = lblalphaletter.text & "<a href=""newsList.aspx?tab=" & iTabnumber & "&catid=" & cat & "&subid=" & cid & "&lb=" & chr(i) & chr(34) & " class=""letter"" title="& chr(i) & ">" & chr(i) & "</a>&nbsp;&nbsp;"
      next

   Case "2"

      lblalphaletter.Text = string.empty
      for i = 65 to 90
         lblalphaletter.text = lblalphaletter.text & "<a href=""newsList.aspx?tab=2&l=" & chr(i) & chr(34) & " class=""letter"" title="& chr(i) & ">" & chr(i) & "</a>&nbsp;&nbsp;"
      next

   Case "3"

      lblalphaletter.Text = string.empty
      for i = 65 to 90
  lblalphaletter.text = lblalphaletter.text & "<a href=""newsList.aspx?tab=" & iTabnumber & "&sid=" & isid & "&lc=" & chr(i) & chr(34) & " class=""letter"" title="& chr(i) & ">" & chr(i) & "</a>&nbsp;&nbsp;"
      next

  End Select

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Display left Panel Category menu
 Sub Choose_Category_Menu()

strSQL = "SELECT *, (SELECT COUNT (*) FROM News WHERE News.CATID = CATEGORY.CATID AND Active = True) AS REC_COUNT FROM CATEGORY ORDER BY CATNAME ASC"

         'Call Open database - connect to the database
         DBconnect()

         Dim LinkAdapter as New OledbDataAdapter(objCommand)
         Dim dts as New DataSet()
         LinkAdapter.Fill(dts, "CATID")

         CategoryName.DataSource = dts.Tables("CATID").DefaultView
         CategoryName.DataBind()

         'Close database
         objConnection.Close()

 End Sub


'++++++++++++++++++++++++++++++++++++++++++++




'++++++++++++++++++++++++++++++++++++++++++++
 'Display 15 newest Links
 Sub Newest_Links()

  strSQL= "Select TOP 10 Date,NewsID,Headline,Hits From ( Select TOP 10 date,NewsID,Headline,Hits From News where active=True order By Date DESC )"

         'Call Open database - connect to the database
         DBconnect()

         Dim LinkAdapter as New OledbDataAdapter(objCommand)
         Dim dts as New DataSet()
         LinkAdapter.Fill(dts, "NewsID")

         NewestLink.DataSource = dts.Tables("NewsID").DefaultView
         NewestLink.DataBind()

         'Close database connection
         objConnection.Close()

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
 'Display 15 most popular Links
 Sub Most_Popular_Links()

    If (CStr(Request.QueryString("tab")) = "1") Then

        CategoryID = Request.QueryString("catid")


strSQL = "SELECT Top 10 NewsID,Headline,Hits FROM News WHERE CatID = " & Replace(CategoryID, "'", "''") & " AND Active = True Order By Hits DESC"

         Else

strSQL= "Select TOP 10 NewsID,Headline,Hits From ( Select TOP 10 date,NewsID,Headline,Hits From News where active=True order By hits DESC )"

    End if

         'Call Open database - connect to the database
         DBconnect()

         Dim LinkAdapter as New OledbDataAdapter(objCommand)
         Dim dts as New DataSet()
         LinkAdapter.Fill(dts, "NewsID")

         PopularLinks.DataSource = dts.Tables("NewsID").DefaultView
         PopularLinks.DataBind()

        'Close database
        objConnection.Close()

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Bind our Data - this is where we bind the data through the conditional structure SQL statements
  Sub BindList()

        'Call custom sort and order parameter
        Sort_Order_Parameter()

        'Call SQL statements
        BindList_SQLStatements()

        'Call db connection string
        DBconnect()

        Dim LinkAdapter As New OledbDataAdapter(objCommand)
        Dim dts As New DataSet

        'Check if page is not postback, then display default
        If Not Page.IsPostBack Then
            LinkAdapter.Fill(dts)
            intRcdCount.text = CStr(dts.Tables(0).Rows.Count)
            dts = Nothing
            dts = New DataSet
        End If

        'Set our page size to 10 on default view
        Dim intPageSize2 As Integer = 10
        Dim intCIndex2 As Integer
        intCIndex2 = intCIndex.text

        LinkAdapter.Fill(dts, CInt(intCIndex2), CInt(intPageSize2), "NewsID")

        LinkCat.DataSource = dts.Tables(0).DefaultView

        LinkCat.DataBind()

        DisplayPageCount()

        TopBreadCrumb_Text()

        HideUnhide_Pager_Panel()

        'Close database
        objConnection.Close()

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'SQL Bind List statements
 Sub BindList_SQLStatements()

  iTabnumber = request("tab")

   Select Case iTabnumber

     Case "1"

        If Request.QueryString("lb") <> "" Then

           Dim Recletter as string
           Recletter = Request.QueryString("lb")

'SQL statement display Link A-Z depending the letter
strSQL = "SELECT *, (Rated/No_RATES) AS RATES From News WHERE CatID = " & Replace(CategoryID, "'", "''") & " AND Headline LIKE '" & Replace(Recletter, "'", "''") & "%' ORDER BY " & Replace(Linksqlorderby, "'", "''") & ""

        Else

'SQL statement display category
strSQL = "SELECT *, (Rated/No_RATES) AS Rates From News WHERE CatID = " & Replace(CategoryID, "'", "''") & " AND Active = True ORDER BY " & Replace(Linksqlorderby, "'", "''") & ""

        End if

    Case "2"

         Dim Recletter as string
         Recletter = Request.QueryString("l")

'SQL statement display Link A-Z depending the letter
strSQL = "SELECT *, (Rated/No_RATES) AS RATES From News WHERE Headline LIKE '" & Replace(Recletter, "'", "''") & "%' ORDER BY " & Replace(Linksqlorderby, "'", "''") & ""

    Case "3"

       If Request.QueryString("lc") <> "" Then

         Dim Recletter as string
         Recletter = Request.QueryString("lc")

'SQL statement display Link A-Z depending the letter
strSQL = "SELECT *, (Rated/No_RATES) AS RATES From News WHERE Active = True AND Headline LIKE '" & Replace(Recletter, "'", "''") & "%' ORDER BY " & Replace(Linksqlorderby, "'", "''") & ""

         Else

'SQL statement display sort 50 most popular,rating,name asc and newest
strSQL = "SELECT TOP 50 *, (Rated/No_RATES) AS Rates From News Where Active = True ORDER BY " & Replace(Linksqlorderby, "'", "''") & ""

        End if

  End Select

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Display the pager link if the records are more than 10, otherwise hide the pager link
 Sub HideUnhide_Pager_Panel()

 'Check if the page has more 10 records and display the paging links
        Dim strCatcounts As Integer
        strCatcounts = intRcdCount.text

        If strCatcounts <= 10 Then

            Panel1.visible = False

        ElseIf strCatcounts > 10 Then

            Panel1.visible = True

        End If

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Display the top bread crumb links name and the record count
 Sub TopBreadCrumb_Text()

        'Display page name on the top page depending the tab #
        If request.querystring("tab") = "1" Then

            lblrcdcounttop.Text = "( " & intRcdCount.text & " )"
            lblcaption.text = strCaption

        ElseIf request.querystring("tab") = "2" Then

            lblbreadcrumdtop.text = "News starting with letter <b>" & request.querystring("l") & "</b>"
            lblrcdcounttop.Text = "( " & intRcdCount.text & " )"
            lblcaption.text = strCaption

        ElseIf request.querystring("tab") = "3" Then

            lblbreadcrumdtop.text = "Sorting News"
            lblcaption.text = strCaption & "&nbsp;<b>50</b> News"

        ElseIf request.querystring("tab") = "4" Then

            lblbreadcrumdtop.text = "50 Most Reviewed News"
            lblcaption.text = strCaption

        End If

        If request.querystring("tab") = "3" And request.querystring("lc") <> "" Then

            lblbreadcrumdtop.text = "Sorting Link"
            lblcaption.text = strCaption & "&nbsp;<b>50</b> News starting with letter&nbsp;<b>" & request.querystring("lc") & "</b>"

        End If

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Handles the sort and order parameter
  Sub Sort_Order_Parameter()

         CategoryID = Request.QueryString("catid")

         action = Request.QueryString("action")
         action = "DATE"
         orderby = "DESC"

        If Request.QueryString("sid") = "" Then
        action = "DATE"
            strCaption = ""

        ElseIf Request.QueryString("sid") = "1" Then
            action = "No_RATES"
            strCaption = "Sorted by: Highest Rated"

        ElseIf Request.QueryString("sid") = "2" Then
            action = "Hits"
            strCaption = "Sorted by: Most Popular"

        ElseIf Request.QueryString("sid") = "3" Then
            action = "DATE"
            strCaption = "Sorted by: Newest"

        ElseIf Request.QueryString("sid") = "4" Then
            action = "Headline"
            strCaption = "Sorted by: Name"

       ElseIf Request.QueryString("sid") = "5" Then
             action = "headline"
            strCaption = "Sorted by: Most Reviewed"

   End If

    'If order ASC or DESC equals blank then grab the default value
    If Request.QueryString("ob") <> "" Then
    orderby = Request.QueryString("ob")
    End If

      'Sort by whether Ascending or Descending
      If orderby = "1" Then
      orderby = "ASC"

        ElseIf orderby = "2" Then
       orderby = "DESC"

        ElseIf orderby > "2" Then
       orderby = "DESC"

     End If

      'Handles the custom sorting SQL statement
      sqlorderby = " " & action & " " & orderby
      Linksqlorderby = "Date"
      if (sqlorderby <> "") then Linksqlorderby = sqlorderby

  End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Conditionally Show an Item in a Bound List - Show popular text or new image depending the condition
  Sub LinkCat_ItemDataBound(sender As Object, e As DataListItemEventArgs)

     'First, make sure we're not dealing with a Header or Footer row
     If e.Item.ItemType <> ListItemType.Header AND e.Item.ItemType <> ListItemType.Footer then

       'Show PopularLabel for items where Hits > 2500
       Dim PopularLabel As Label = CType(e.Item.FindControl("lblpopular"), Label)
       Dim strPopular as Integer = DataBinder.Eval(e.Item.DataItem, "Hits")
       Dim handImage As Image = CType(e.Item.FindControl("thumb"), Image)

          If strPopular > 1500 Then

             handImage.ImageUrl = "images/hnd.gif"
             handImage.visible = true
             PopularLabel.visible = True
             PopularLabel.text = "Popular"

          End if

       'Show a newimage for items where items not older than 1 week
       Dim strDate as Date = DataBinder.Eval(e.Item.DataItem, "DATE")
       Dim Newimage As Image = CType(e.Item.FindControl("newimg"), Image)

       Dim DateSince as string

          DateSince = DateDiff("d", DateTime.Now, strDate) + 7

            If DateSince >= 0 Then

                 Newimage.ImageUrl = "images/new.gif"

            Else

                Newimage.visible = False

            End If

    End if

  If e.Item.ItemType <> ListItemType.Header AND e.Item.ItemType <> ListItemType.Footer then

         Dim intCatID as integer
         Dim intSubID as integer
         Dim strLCatName as string
         Dim strLSubName as string

         intCatID = DataBinder.Eval(e.Item.DataItem, "CATID")

         Dim catnamelabel As Label = CType(e.Item.FindControl("lblcatname2"), Label)

Dim CmdCatName2 As New OleDbCommand("Select CATNAME From CATEGORY Where CATID=" & intCatID & "", New OleDbConnection(strConnection))
        CmdCatName2.Connection.Open()
        strLCatName = CmdCatName2.ExecuteScalar()
        catnamelabel.text = strLCatName
        CmdCatName2.Connection.Close()


 end if

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
 Sub LinkAndLabel_TextDisplay()

   iTabnumber = request("tab")

    Select Case iTabnumber

       Case "1"

         lblletter.Text = "&nbsp;A-Z:"

       Case "2"

         lblletter.Text = "All News Links A-Z:"
         lblCategoryNameFooter.text = "You are here in All News Alphabetical Listing"

       Case "3"

         lblletter.Text = "Sorted News A-Z:"
         lblCategoryNameFooter.text = "You are here in Quick Sort"

case else
response.end
     End select

         'Label for side panel header text
         lblsortcat.text = "Sort Option"

         HyperLink1.NavigateUrl = "index.aspx"
         HyperLink1.Text = "Home"
         HyperLink1.ToolTip = "Back to Link homepage"

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Display record count,page number
  Sub DisplayPageCount()

       lblRecpage.Text = "Total News:<b>&nbsp;" & intRcdCount.text
       lblRecpage.Text += "</b> - Showing Page:<b> "
       lblRecpage.Text += CStr(CInt(CInt(intCIndex.text) / CInt(intPageSize.text)+1))
       lblRecpage.Text += "</b> of <b>"

     If (CInt(intRcdCount.Text) Mod CInt(intPageSize.text)) > 0 Then
       lblRecpage.Text += CStr(CInt(CInt(intRcdCount.text) / CInt(intPageSize.text)+1))
     Else
       lblRecpage.Text += CStr(CInt(intRcdCount.text) / CInt(intPageSize.text))
     End If
       lblRecpage.Text += "</b>"

  End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Jump to the first page - paging link
  Sub ShowFirst(ByVal s As Object, ByVal e As EventArgs)

       intCIndex.Text = "0"
       BindList()

  End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Back to previous page - paging link
  Sub ShowPrevious(ByVal s As Object, ByVal e As EventArgs)

     intCIndex.text = Cstr(Cint(intCIndex.text) - CInt(intPageSize.text))

      If CInt(intCIndex.text) < 0 Then
        intCIndex.Text = "0"
      End If

     BindList()

  End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Go to next page - paging link
  Sub ShowNext(ByVal s As Object, ByVal e As EventArgs)

    If CInt(intCIndex.text) + 1 < CInt(intRcdCount.text) Then
      intCIndex.text = CStr(CInt(intCIndex.text) + CInt(intPageSize.text))
    End If

    BindList()

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Jump to last page - paging link
  Sub ShowLast(ByVal s As Object, ByVal e As EventArgs)

      Dim itemp as Integer

      itemp = CInt(intRcdCount.text) Mod CInt(intPageSize.text)

        If itemp > 0 Then
          intCIndex.text = Cstr(CInt(intRcdCount.text) - itemp)
        Else
          intCIndex.text = Cstr(CInt(intRcdCount.text) - CInt(intPageSize.text))
       End If

       BindList()

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
  'Display category name in the breadcrum top link
  Sub Get_Cat_Name()

 if request("tab") = "1" then

 Dim CmdCatName As New OleDbCommand("Select CATNAME From CATEGORY Where CATID=" & request("catid") & "", New OleDbConnection(strConnection))
        CmdCatName.Connection.Open()
        lblCategoryName.Text = CmdCatName.ExecuteScalar()
        CmdCatName.Connection.Close()

 end if

  End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
  'Display sub-category name in the breadcrumb top link
  'Sub Get_SubCat_Name()

  'if request("tab") = "1" then

 'Dim CmdCatName As New OleDbCommand("Select SUBNAME From SUBCATEGORY Where SUBID=" & request("subid") & "", New OleDbConnection(strConnection))
    ' CmdCatName.Connection.Open()
    ' lblSubCatName.Text = CmdCatName.ExecuteScalar()
     ' CmdCatName.Connection.Close()

  'end if

  'End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
'Display sort option links - Here we check what tab we are viewing, and then display the corresponding custom sort links
  Sub Sort_Category_Links()

    Dim iTabnumber as Integer = request("tab")

    Select case iTabnumber

        Case "1"

                Tab1_CustomSortLinks()

        Case "2"

                Tab2_CustomSortLinks()

        Case "3"

               Tab3_CustomSortLinks()

        Case "4"

               Tab4_CustomSortLinks()
case else
response.end
    End Select

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
 Sub Tab1_CustomSortLinks()

      Dim strRecletter As String
      Dim strLb As String
      Dim strRflag as integer
      Dim CatIDS as integer
      strRflag = Request.QueryString("r")
      strRecletter = Request.QueryString("l")
      strSid = Request.QueryString("sid")
      strOB = Request.QueryString("ob")
      CategoryID = Request.QueryString("catid")
      CatIDS = Request.QueryString("catid")
      strLb = Request.QueryString("lb")

            LinkReset.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID
            LinkReset.Text = "Reset"
            LinkReset.ToolTip = "Back to Category default view"

            'Here we check what field are we going to sort, this depends the strSid value
            If strSid = "2" Then
            LinkMostPopular.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 2 & "&ob=" & 1 & "&r=" & 1
              LinkMostPopular.Text = "Most Popular"
              LinkMostPopular.ToolTip = "Sort Category by Most Popular Links ASC"
            Else
              LinkMostPopular.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 2 & "&ob=" & 2 & "&r=" & 2
              LinkMostPopular.Text = "Most Popular"
              LinkMostPopular.ToolTip = "Sort Category by Most Popular Links DESC"

                'Check the strSid value and hide arrow up and arrow down image
                If strSid <> 2 Then

                    ArrowImage2.visible = False

                End If

            End If

            'Check if both values are true, and change the url depending on the values
            If strSid = "2" And strOB = "1" Then

             LinkMostPopular.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 2 & "&ob=" & 2 & "&r=" & 2
             LinkMostPopular.Text = "Most Popular"
             LinkMostPopular.ToolTip = "Sort Category by Most Popular Links DESC"
             ArrowImage2.ImageUrl = "images/arrow_up.gif"

            End If

            If strSid = "2" And strOB = "2" Then

                ArrowImage2.ImageUrl = "images/arrow_down.gif"

            End If

             'We check if we are dealing with alphabet letter sorting
            If strLb <> "" AND strRflag = "1" Then

             LinkMostPopular.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 2 & "&ob=" & 2 & "&r=" & 2
                LinkMostPopular.Text = "Most Popular"
                LinkMostPopular.ToolTip = "Sort by Most Popular Links DESC"
                ArrowImage2.ImageUrl = "images/arrow_up.gif"

            Elseif strLb <> "" AND strRflag = "2" Then

             LinkMostPopular.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 2 & "&ob=" & 1 & "&r=" & 1
                LinkMostPopular.Text = "Most Popular"
                LinkMostPopular.ToolTip = "Sort by Most Popular Links ASC"
                ArrowImage2.ImageUrl = "images/arrow_down.gif"

            ElseIf strLb <> "" Then

                LinkMostPopular.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 2 & "&ob=" & 2 & "&r=" & 2
                LinkMostPopular.Text = "Most Popular"
                LinkMostPopular.ToolTip = "Sort Category by Most Popular Links DESC"
                'ArrowImage2.ImageUrl = "images/arrow_down.gif"

            End If


            If strSid = "1" Then
              LinkHighestRated.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 1 & "&ob=" & 1 & "&r=" & 1
              LinkHighestRated.Text = "Highest Rated"
              LinkHighestRated.ToolTip = "Sort Category by Highest Rated Links ASC"
            Else
              LinkHighestRated.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 1 & "&ob=" & 2 & "&r=" & 2
              LinkHighestRated.Text = "Highest Rated"
              LinkHighestRated.ToolTip = "Sort Category by Highest Rated Links DESC"

                If strSid <> 1 Then

                    ArrowImage.visible = False

                End If

            End If


            If strSid = "1" And strOB = "1" Then

              LinkHighestRated.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb &"&sid=" & 1 & "&ob=" & 2 & "&r=" & 2
              LinkHighestRated.Text = "Highest Rated"
              LinkHighestRated.ToolTip = "Sort Category by Highest Rated Links DESC"
                ArrowImage.ImageUrl = "images/arrow_up.gif"

            End If

            If strSid = "1" And strOB = "2" Then

                ArrowImage.ImageUrl = "images/arrow_down.gif"

            End If


            If strSid = "3" Then
                NewestLinkest.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 3 & "&ob=" & 1 & "&r=" & 1
                NewestLinkest.Text = "Newest"
                NewestLinkest.ToolTip = "Sort Category by Newest Links ASC"
            Else
                NewestLinkest.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 3 & "&ob=" & 2 & "&r=" & 2
                NewestLinkest.Text = "Newest"
                NewestLinkest.ToolTip = "Sort Category by Newest Links DESC"

                If strSid <> 3 Then

                    ArrowImage3.visible = False

                End If

            End If


            If strSid = "3" And strOB = "1" Then

                NewestLinkest.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 3 & "&ob=" & 2 & "&r=" & 2
                NewestLinkest.Text = "Newest"
                NewestLinkest.ToolTip = "Sort Category by Newest Links DESC"
                ArrowImage3.ImageUrl = "images/arrow_up.gif"

            End If

            If strSid = "3" And strOB = "2" Then

                ArrowImage3.ImageUrl = "images/arrow_down.gif"

            End If


            If strSid = "4" Then
                LinkName.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 4 & "&ob=" & 1 & "&r=" & 1
                LinkName.Text = "Headline"
                LinkName.ToolTip = "Sort Category by Link Name ASC"
            Else
                LinkName.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&lb=" & strLb & "&sid=" & 4 & "&ob=" & 2 & "&r=" & 2
                LinkName.Text = "Name"
                LinkName.ToolTip = "Sort Category by Link Name DESC"

                If strSid <> 4 Then

                    ArrowImage4.visible = False

                End If

            End If


            If strSid = "4" And strOB = "1" Then

                LinkName.NavigateUrl = "newsList.aspx?tab=1&catid=" & CatIDS & "&subid=" & CategoryID & "&sid=" & 4 & "&ob=" & 2 & "&r=" & 2
                LinkName.Text = "Name"
                LinkName.ToolTip = "Sort Category by News Headline DESC"
                ArrowImage4.ImageUrl = "images/arrow_up.gif"

            End If

            If strSid = "4" And strOB = "2" Then

                ArrowImage4.ImageUrl = "images/arrow_down.gif"

            End If

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
 Sub Tab2_CustomSortLinks()

      Dim strRecletter As String
      Dim strRflag as integer
      strRecletter = Request.QueryString("l")
      strSid = Request.QueryString("sid")
      strOB = Request.QueryString("ob")

            LinkReset.visible = False

            If strSid = "2" Then
                LinkMostPopular.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 2 & "&ob=" & 1
                LinkMostPopular.Text = "Most Popular"
                LinkMostPopular.ToolTip = "Sort by Most Popular Links ASC"
            Else
                LinkMostPopular.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 2 & "&ob=" & 2
                LinkMostPopular.Text = "Most Popular"
                LinkMostPopular.ToolTip = "Sort by Most Popular Links DESC"

                If strSid <> 2 Then

                    ArrowImage2.visible = False

                End If

            End If


            If strSid = "2" And strOB = "1" Then

                LinkMostPopular.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 2 & "&ob=" & 2
                LinkMostPopular.Text = "Most Popular"
                LinkMostPopular.ToolTip = "Sort by Most Popular Links DESC"
                ArrowImage2.ImageUrl = "images/arrow_up.gif"

            End If

            If strSid = "2" And strOB = "2" Then

                ArrowImage2.ImageUrl = "images/arrow_down.gif"

            End If


            If strSid = "1" Then
                LinkHighestRated.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 1 & "&ob=" & 1
                LinkHighestRated.Text = "Highest Rated"
                LinkHighestRated.ToolTip = "Sort by Highest Rated Links ASC"
            Else
                LinkHighestRated.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 1 & "&ob=" & 2
                LinkHighestRated.Text = "Highest Rated"
                LinkHighestRated.ToolTip = "Sort by Highest Rated Links DESC"

                If strSid <> 1 Then

                    ArrowImage.visible = False

                End If

            End If


            If strSid = "1" And strOB = "1" Then

                LinkHighestRated.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 1 & "&ob=" & 2
                LinkHighestRated.Text = "Highest Rated"
                LinkHighestRated.ToolTip = "Sort by Highest Rated Links DESC"
                ArrowImage.ImageUrl = "images/arrow_up.gif"

            End If

            If strSid = "1" And strOB = "2" Then

                ArrowImage.ImageUrl = "images/arrow_down.gif"

            End If


            If strSid = "3" Then
                NewestLinkest.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 3 & "&ob=" & 1
                NewestLinkest.Text = "Newest"
                NewestLinkest.ToolTip = "Sort by Newest Links ASC"
            Else
                NewestLinkest.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 3 & "&ob=" & 2
                NewestLinkest.Text = "Newest"
                NewestLinkest.ToolTip = "Sort by Newest Links DESC"

                If strSid <> 3 Then

                    ArrowImage3.visible = False

                End If

            End If


            If strSid = "3" And strOB = "1" Then

                NewestLinkest.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 3 & "&ob=" & 2
                NewestLinkest.Text = "Newest"
                NewestLinkest.ToolTip = "Sort by Newest Links DESC"
                ArrowImage3.ImageUrl = "images/arrow_up.gif"

            End If

            If strSid = "3" And strOB = "2" Then

                ArrowImage3.ImageUrl = "images/arrow_down.gif"

            End If


            If strSid = "4" Then
                LinkName.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 4 & "&ob=" & 1
                LinkName.Text = "Name"
                LinkName.ToolTip = "Sort by Link Name ASC"
            Else
                LinkName.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 4 & "&ob=" & 2
                LinkName.Text = "Name"
                LinkName.ToolTip = "Sort by Link Name DESC"

                If strSid <> 4 Then

                    ArrowImage4.visible = False

                End If

            End If


            If strSid = "4" And strOB = "1" Then

                LinkName.NavigateUrl = "newsList.aspx?tab=2&l=" & strRecletter & "&sid=" & 4 & "&ob=" & 2
                LinkName.Text = "Name"
                LinkName.ToolTip = "Sort by Link Name DESC"
                ArrowImage4.ImageUrl = "images/arrow_down.gif"

            End If

            If strSid = "4" And strOB = "2" Then

                ArrowImage4.ImageUrl = "images/arrow_up.gif"

            End If

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
 Sub Tab3_CustomSortLinks()

      strSid = Request.QueryString("sid")
      strOB = Request.QueryString("ob")

            ArrowImage.visible = False
            ArrowImage2.visible = False
            LinkReset.visible = False

            If strOB = "1" Then
   &
 
Old January 14th, 2006, 12:36 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Heuh??????

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Big Night Out by Fun Lovin' Criminals (Track 12 from the album: 100% Colombian) What's This?
 
Old January 14th, 2006, 01:24 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what????

 
Old January 14th, 2006, 01:43 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I noticed sth.because <asp:image id="img1" runat="server" /> is located in <itemTemplate in a datalist server control I got that error message.
when I put it outside of datalist block the problem is solved.
Now what should I do?I want it to be in datalist.!!!!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Image to Image Control using JavaScript ctranjith General .NET 1 May 28th, 2013 05:43 AM
Tutorial to an web server control simsen ASP.NET 2.0 Professional 0 January 15th, 2008 04:29 AM
Need help with web server control and design binici ASP.NET 2.0 Basics 1 December 20th, 2006 11:59 AM
Web Image with kodak imgedit control MK2 VB Components 1 June 15th, 2004 11:08 PM
HyperLink web server control style acko ASP.NET 1.0 and 1.1 Basics 2 November 14th, 2003 02:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.