小编Sha*_*one的帖子

解析错误:语法错误,意外' - >'(T_OBJECT_OPERATOR)

我有一种感觉,这可能是一个简单的语法错误,我只是没有看到,因为我有一个代码,并且无法弄清楚为什么我得到上述错误.我正在处理的代码是SAMS书籍的教程,用于构建日历类.为了记录,我正在运行PHP 5.4.7.以下代码属于我将在下面显示的包含..

function date_pulldown($name) {
    $this->name = $name;
}

function setDate_global( ) {
    if (!this->setDate_array($GLOBALS['$this->name'])) {
        return $this->setDate_timestamp(time());
    }

    return true;
}

function setDate_timestamp($time) {
    $this->timestamp = $time;
    return true;
}

function setDate_array($inputdate) {
    if (is_array($inputdate) &&
        isset($inputdate["mon"]) &&
        isset($inputdate["mday"]) &&
        isset($inputdate["year"])) {

        $this->timestamp = mktime(11, 59, 59, $inputdate["mon"], $inputdate["mday"], $inputdate["year"]);

        return true;
    }

    return false;       
}

function setYearStart($year) {
    $this->yearstart = $year;
}

function setYearEnd($year) {
    $this->yearend = $year;
}

function getYearStart() {
    if ($this->yearstart < 0) {
        $nowarray …
Run Code Online (Sandbox Code Playgroud)

php syntax-error

3
推荐指数
2
解决办法
3万
查看次数

尝试将选定的DropDownList传递给Session

我正在尝试将下拉列表的值传递给会话变量,然后将此值转换为审阅页面的文本标签.然后需要将此值传递给sql表(不是问题).问题在于每当我尝试调用标签中的下拉列表的值(或索引,我已尝试过两者)时,我都会得到一个null异常.这是我在第一页上的一个下拉列表的代码,以及尝试在下一个页面上创建的会话中绑定它:FirstPage.aspx

<asp:DropDownList ID="ddlInnoc" runat="server">
<asp:ListItem Value="0">No</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
</asp:DropDownList>
Run Code Online (Sandbox Code Playgroud)

FirstPage.aspx.cs

Session["Jabs"] = ddlInnoc.SelectedIndex;
Run Code Online (Sandbox Code Playgroud)

SecondPage.aspx

<asp:Label ID="lblJabs" runat="server"></asp:Label>
Run Code Online (Sandbox Code Playgroud)

SecondPage.aspx.cs

lblJabs.Text = Session["Jabs"].ToString();
Run Code Online (Sandbox Code Playgroud)

请有人告诉我,我只是愚蠢!我收到的例外情况如下:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


Line 11: …
Run Code Online (Sandbox Code Playgroud)

c# asp.net session drop-down-menu

1
推荐指数
1
解决办法
3906
查看次数

标签 统计

asp.net ×1

c# ×1

drop-down-menu ×1

php ×1

session ×1

syntax-error ×1