Link button dont work in FireFox and Internet Explorer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • XolileWarren
    New Member
    • Dec 2008
    • 4

    Link button dont work in FireFox and Internet Explorer

    Can anyone help?

    I have a gridview and two link buttons;back and previous to navigate back and forward the page is working fine on Opera but the link button is not active when using FireFox and Internet explorer.The code is as follows

    Any kind of help will be appreciated
    [code=aspx]
    <%@ Page Language="C#" MasterPageFile= "~/mymAdmin/Main.Master" AutoEventWireup ="true" CodeFile="inbox .aspx.cs" Inherits="inbox " Title="LoveLife :: Mymsta Inbox" %>

    <asp:Content ID="Content2" ContentPlaceHol derID="cphMenu" runat="server">
    <asp:Label ID="lblPageTitl e" Text="Message Inbox" runat="server" ForeColor="Whit e" Font-Bold="true" Font-Size="Small">
    </asp:Label>
    <hr />
    <asp:Label ID="lblInboxMen u" runat="server"> </asp:Label>
    </asp:Content>

    <asp:Content ID="Content3" ContentPlaceHol derID="cphMain" runat="server">
    <table style="height: 329px">
    <tr><td>
    <asp:DataGrid ID="dgMessages " runat="server" Width="800px"
    HeaderStyle-Font-Bold="true" AllowPaging="Tr ue" Height="100px"
    HorizontalAlign ="Right" >
    <AlternatingIte mStyle BackColor="Dark Gray" Font-Bold="False" Font-Italic="False"
    Font-Overline="False " Font-Strikeout="Fals e" Font-Underline="Fals e" />
    <ItemStyle HorizontalAlign ="Left" />
    <HeaderStyle Font-Bold="True" ForeColor="#339 9FF" HorizontalAlign ="Left" />
    <PagerStyle Mode="NumericPa ges" HorizontalAlign ="Left" Visible="False" />
    </asp:DataGrid>
    </td></tr>
    <tr><td style="height: 100px">
    <asp:LinkButt on ID="lbtnPreviou s" runat="server" Text="Previous" OnClick="lbtnPr evious_Click" />
    <asp:LinkButt on ID="lbtnNext" runat="server" Text="Next" OnClick="lbtnNe xt_Click" />
    <br /><asp:Label ID="lblMsg" runat="server" ForeColor="Whit e"></asp:Label>
    </td></tr>
    </table>
    </asp:Content>
    [/code]
    [code=cpp]
    private int BindGrid(Int64 id, int currentPage)
    {
    int tp;
    //UserDataSet.Mes sagesDataTable mt = MessageManager. GetMessagesByRe cipient(id);
    UserDataSet.Mes sagesDataTable mt = MessageManager. GetMessagesByRe cipientPagedOld estFirst(id, currentPage, 10, out tp);

    int numMessages = mt.Rows.Count;

    //create a new datatable with minimal columns
    DataTable dt = new DataTable("Mess ages");

    DataColumn dcU = new DataColumn("Use r");
    DataColumn dcT = new DataColumn("Mes sage title");
    DataColumn dcB = new DataColumn("Mes sage body");
    DataColumn dcD = new DataColumn("Dat e sent");
    DataColumn dcM = new DataColumn("-----");

    dt.Columns.Add( dcU);
    dt.Columns.Add( dcT);
    dt.Columns.Add( dcB);
    dt.Columns.Add( dcD);
    dt.Columns.Add( dcM);

    for (int i = 0; i < numMessages; i++)
    {
    if (!mt[i].isRead)
    {
    UserDataSet.Mes sagesRow dr = (UserDataSet.Me ssagesRow)mt.Ro ws[i];
    DataRow drNew = dt.NewRow();

    //get the name of the sender
    UserDataSet.Use rsRow ur = UserManager.Get UserByUserID(Sy stem.Convert.To Int64(mt[i].UserIDSender)) ;
    drNew["User"] = ur.UserName;

    Int64 uid = mt[i].UserIDSender;
    Int64 mid = mt[i].MessageID;

    string q = "<a href='reply.asp x?msgid=" + mid.ToString() +
    "&uid=" + uid.ToString() +
    "&id=" + id.ToString() +
    "'>" +
    mt[i].MessageTitle + "</a>";
    drNew["Message title"] = q;

    drNew["Message body"] = mt[i].MessageBody;
    drNew["Date sent"] = mt[i].SentDate;

    string m = "<a href='inbox.asp x?msgid=" + mt[i].MessageID.ToSt ring() +
    "'>Mark as read</a>";
    drNew["-----"] = m;

    dt.Rows.Add(drN ew);
    }
    }

    dgMessages.Data Source = dt;
    dgMessages.Data Bind();

    return tp;

    private void InitialPageLoad ()
    {
    ViewState["current_pa ge"] = 1;
    ViewState["current_record "] = 0;

    Int64 id = GetId();

    int cp = (int)ViewState["current_pa ge"];
    if (cp == 1)
    lbtnPrevious.En abled = false;

    int totalPages = BindGrid(id, cp);

    //int numPages = (totalMessages / 4);

    if (cp == totalPages)
    lbtnNext.Enable d = false;
    else
    lbtnNext.Enable d = true;

    lblMsg.Text = "Page " + cp + " of " + totalPages;

    //lblMsg.Text = totalMessages + " messages. Num pages: " + numPages;
    }

    private void SecondaryPageLo ad()
    {
    string ob = (string)ViewSta te["sort"];
    string p = (string)ViewSta te["param"];
    int cr = (int)ViewState["current_record "];
    int cp = (int)ViewState["current_pa ge"];

    if (ob == "desc")
    ob = "asc";
    else
    ob = "desc";

    ViewState["sort"] = ob;

    if (cr == 0)
    lbtnPrevious.En abled = false;

    string uid = (string)Session["userid"];
    //int i = BindGrid(uid, cr, 5, p, ob);

    //lblMsg.Text = "Page " + cp + " of " + i;
    }
    protected void dgMessages_Sort Command(object source, DataGridSortCom mandEventArgs e)
    {
    ViewState["param"] = e.SortExpressio n;

    string ob = (string)ViewSta te["sort"];
    string p = (string)ViewSta te["param"];
    int cr = (int)ViewState["current_record "];

    switch (p)
    {
    case "Ad name":
    p = "an";
    break;
    case "Status":
    p = "a";
    break;
    case "Times served":
    p = "ts";
    break;
    case "Type":
    p = "ib";
    break;
    case "Date uploaded":
    p = "du";
    break;
    default:
    p = (string)ViewSta te["param"];
    break;
    }

    ViewState["param"] = p;
    string uid = (string)Session["userid"];
    //int i = BindGrid(uid, cr, 5, p, ob);
    }
    protected void lbtnNext_Click( object sender, EventArgs e)
    {
    //long uid = GetId();
    //int cp = (int)ViewState["current_pa ge"];

    //lbtnPrevious.En abled = true;

    //cp += 1;
    //ViewState["current_pa ge"] = cp;

    //int tp = BindGrid(uid, cp); //returns the total number of pages

    //if (cp >= tp)
    // lbtnNext.Enable d = false;
    //else
    // lbtnNext.Enable d = true;

    //if (tp == 0)
    // lblMsg.Text = "No records.";
    //else
    // lblMsg.Text = "Page " + cp + " of " + tp;

    long uid = GetId();
    int cp = (int)ViewState["current_pa ge"];

    lbtnPrevious.En abled = true;

    cp += 1;
    ViewState["current_pa ge"] = cp;

    int tp = BindGrid(uid, cp); //returns the total number of pages

    if (cp >= tp)
    lbtnNext.Enable d = false;
    else
    lbtnNext.Enable d = true;

    if (tp == 0)
    lblMsg.Text = "No records.";
    else
    lblMsg.Text = "Page " + cp + " of " + tp;
    }

    protected void lbtnPrevious_Cl ick(object sender, EventArgs e)
    {
    int cp = (int)ViewState["current_pa ge"];

    lbtnNext.Enable d = true;

    cp -= 1;
    if (cp <= 1)
    {
    cp = 1;
    lbtnPrevious.En abled = false;
    }
    else
    lbtnPrevious.En abled = true;

    ViewState["current_pa ge"] = cp;

    long uid = GetId();
    int tp = BindGrid(uid, cp);

    if (tp == 0)
    lblMsg.Text = "No records for this connection";
    else
    lblMsg.Text = "Page " + cp + " of " + tp;
    [/code]
    Thanks,in advance
    Last edited by Frinavale; Dec 2 '08, 08:29 PM. Reason: added [code] tags
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by XolileWarren
    Can anyone help?

    I have a gridview and two link buttons;back and previous to navigate back and forward the page is working fine on Opera but the link button is not active when using FireFox and Internet explorer.The code is as follows
    ...
    Any kind of help will be appreciated

    Thanks,in advance
    What version of Visual Studio are you using? Have you considered stepping through your code with the debugger to see what's going on? You can test in different browsers by setting the browser you want to test with as your default browser (if you're using VS 2008).

    I have a feeling it has something to do with you disabling the link buttons in your Page Load event.

    Have you considered simply using the paging capability built into the GridView control? This might solve all of your problems.


    In the future only post code that is relevant to the problem you're facing. It makes it very hard for us to help you if we have to read through all of your code just to find a line or two that pertains to your question. Also, when posting code, please remember to use code tags.

    -Frinny

    Comment

    • XolileWarren
      New Member
      • Dec 2008
      • 4

      #3
      Link button dont work in FireFox and Internet Explorer Reply to Thread

      I managed to find the problem, I used FireFox development tools, and when I removed all the CSS and tested the link button everything was working fine.

      Thanks for your help

      Comment

      Working...