小编Zub*_*air的帖子

为什么我的foreach中的代码无法访问?(已经过单元测试的工作代码的确切副本)

下面的代码是一个完美的代码的精确副本.不同之处在于此代码放在WCF服务应用程序项目中,而工作代码来自Windows窗体应用程序项目.foreach中的代码是无法访问的,这很奇怪,因为我之前测试过代码并且它有效,返回正确的值

public IEnumerable<Employee> GetStudentDetails(string username,string password)
    {
        var emp = agrDb.LoginAuthentication(username, password);//procedure in the database thats returning two values
                                                                //Namely: EmployeeFirstName and EmployeeLastName
        List<Employee> trainerList = new List<Employee>();

        foreach (var item in emp)
        {
            //unreachable code here
            Employee employ = new Employee();
            employ.EmployeeFirstName = item.EmployeeFirstName;
            employ.EmployeeLastName = item.EmployeeLastName;
            trainerList.Add(employ);
            //trainerList.Add(item.EmployeeLastName);
        }
        return trainerList;
    }
Run Code Online (Sandbox Code Playgroud)

c# foreach wcf unreachable-code

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

在回发后,jquery不验证控件并允许提交

我正在使用JQuery验证插件验证表单.

页面第一次加载时,表单将完美验证,并且只有在完成所有字段后才会提交.然后表单回发给自己,当尝试再次输入详细信息时,验证不起作用但仍然允许提交并且数据成功发送到数据库.

这是我的代码:

<form id="formSubmit" method="post" action="post to this page">


<fieldset data-role="fieldcontain">
            <p>
                <label for="clubSelect">Preferred Club</label>                  
                <select id="clubSelect" name="clubSelect" class="required">
                    <option value="000">Select a Club</option>
                    <?php if ($db->num_rows > 0)
                        {
                            foreach($results as $result)
                            {
                    ?>
                    <option value="<?php echo $result->id;?>"><?php echo $result->name;?></option>
                    <?php 
                            }
                        }
                    ?>
                </select>
                </fieldset>
            <fieldset data-role="fieldcontain">
                <label for="txtName">Name</label>
                <input type="text" id="txtName" name="txtName" class="required"/>
            </fieldset>
            <fieldset data-role="fieldcontain">
                <label for="txtEmail">Email</label>
                <input type="text" id="txtEmail" name="txtEmail" class="required email" minlength="5"/>
                    </fieldset>
                    <fieldset data-role="fieldcontain">
                <label for="txtCell">Contact Number</label>
                <input type="tel" id="txtCell" name="txtCell" class="required"/>
            </fieldset> …
Run Code Online (Sandbox Code Playgroud)

php validation jquery jquery-validate jquery-mobile

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