1

スクリプトsrc="http://code.jquery.com/jquery-1.7.1.min.jsがaspxページで有効になっている場合、次のコードはaspx.csページで実行されません。jqueryを無効にすると、コードは完全に機能します。問題のコードは、コードビハインドのIsPostbackにあります。

aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="resolution_finder.aspx.cs" Inherits="client_mobile_tickets_resolution_finder" Debug="true" %>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />

    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>

    <link rel="apple-touch-icon" href="images/apple-touch-icon.png" />
    <link rel="shortcut icon" type="image/ico" href="favicon.ico">

     <style type="text/css">
        .ui-btn-text {
            font-size: 15px; 
        }
    </style>

    <script type="text/javascript" language="javascript">

        function init_Timer() {
            //-- Log out after 5 minutes
            var timeout = parseInt('<%=timeout %>');
            setTimeout('logOut()', timeout);
        }

        function logOut() {
            document.location = '<%=serverName %>/mobile_support/log_off.aspx?uid=<%=uid %>';
        }

    </script>    

    <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
</head>
<body onload="init_Timer();">
    <form id="frmMain" runat="server">
        <div data-role="page" data-theme="b" id="pg1" name="pg1" >

            <div data-role="header">
                <div class="ui-bar ui-bar-a" style="text-align:center; height:30px; " >
                    <h1 style="white-space: normal">Resolution Finder</h1>
                </div>
            </div><!-- /header -->

            <div data-role="content">
                <label for="ddl">Select an Issue:</label><br />
                    <asp:DropDownList ID="ddlSubject" runat="server" DataSourceID="sdsSubject" 
                        DataTextField="issue" DataValueField="issue" >
                    </asp:DropDownList><br />

                    <asp:SqlDataSource ID="sdsSubject" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:mobile %>" 
                        SelectCommand="get_sl_top_20_issues_p" SelectCommandType="StoredProcedure">
                    </asp:SqlDataSource>

                <asp:Button ID="cmdGo" runat="server" Text="Show Solution(s)" 
                    data-icon="search" theme="a" onclick="cmdGo_Click" />

             </div><!-- /Content -->

             <div data-role="footer" data-position="fixed">
                <div data-role="navbar" style="white-space: normal;" >
                    <ul>
                        <li><a href="<%=serverName %>/mobile_support/home.aspx?uid=<%=uid %>">Home</a></li>
                        <li><a href="active.aspx?uid=<%=uid %>">Active Tickets</a></li>
                        <li><a href="#" onclick="document.location='<%=serverName%>/mobile_support/log_off.aspx?uid=<%=uid %>&logOff=1';">Log Off</a></li>
                    </ul>
                </div>            
            </div><!-- /Footer -->

        </div><!-- /Page -->

   </form>
</body>
</html>

aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public partial class client_mobile_tickets_resolution_finder : System.Web.UI.Page
{
    public int uid;
    public static DataTable dt;
    public string serverName;
    public string timeout;
    public int rowCount;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            //--ClientScript.RegisterStartupScript(this.GetType(), "hash", "window.location.hash='#pg2';", true);
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>showResults();</script>", false);
        }
        serverName = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority; // + HttpContext.Current.Request.ApplicationPath;

        //Get uid
        uid = int.Parse(Request.QueryString["uid"]);

        //Open database connection
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mobile"].ConnectionString);
        try
        {
            conn.Open();

            ////-- Test to be sure db is open
            if (conn.State == ConnectionState.Open)
            {
                //--Get Home screen data
                SqlDataAdapter ad = new SqlDataAdapter("get_mobile_server_info_p", conn);
                DataSet ds = new DataSet();

                ad.Fill(ds, "dsResult");
                dt = ds.Tables[0];
                timeout = dt.Rows[0][2].ToString();
            }
            else
            {
                Response.Write("Error.....  Could not open dataset....");
                Response.End();
            }
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }

    protected void cmdGo_Click(object sender, EventArgs e)
    {
        //--Get actions for selected issue

        //Open database connection
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mobile"].ConnectionString);
        try
        {
            conn.Open();

            ////-- Test to be sure db is open
            if (conn.State == ConnectionState.Open)
            {
                //--Get resolutions
                SqlDataAdapter ad = new SqlDataAdapter("get_sl_actions_for_issue_p '" + ddlSubject.SelectedValue + "'", conn);
                DataSet ds = new DataSet();

                ad.Fill(ds, "dsResult");
                dt = ds.Tables[0];

                rowCount = dt.Rows.Count;

                //-- Populate the results
                DataTable newsDataTable = new DataTable();

                // add some columns to our datatable
                newsDataTable.Columns.Add("href_li");
                newsDataTable.Columns.Add("DisplayText");

                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    DataRow newsDataRow = newsDataTable.NewRow();
                    newsDataRow["href_li"] = i;
                    newsDataRow["DisplayText"] = dt.Rows[i][0].ToString();
                    newsDataTable.Rows.Add(newsDataRow);
                }
                menu_ul_1.DataSource = newsDataTable;
                menu_ul_1.DataBind();

                //--Navigate to the 2nd page
                //--this.ClientScript.RegisterStartupScript(this.GetType(),"navigate", "window.location.hash='#pg2';",true);
                //--Response.RedirectPermanent("resolution_finder.aspx?uid=" + uid + "#pg2");
            }
            else
            {
                Response.Write("Error.....  Could not open dataset....");
                Response.End();
            }
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }
}
4

0 に答える 0