This is the default.aspx, there are a lot of generated forms like buttons/textbox/etc and they are all having their own unique id like comment_<%StuCount%> which looped through. It was made by an intern before me and I am new so I have no clue what I am doing.

<asp:Repeater ID='Evaluations' runat='server' Visible="false">
    <HeaderTemplate>
        <p align='center'><b><font size='4' face='Arial, Helvetica, sans-serif'>
            <%
                Response.Write(Session("Course"))
                If Session("Track") = 1 Then Response.Write(" Course")
            %>
        </font></b></p>
        <p align="center"><b><font size="2" face="Arial, Helvetica, sans-serif">Please use this form to evaluate your own professional behavior and that of<br>the other members of your group in the 
        <%
            Response.Write("<b>" & theCourse & "</b>")
            If Session("Track") = 1 Then Response.Write(" course")
        %> 
        .</font></b></p><p align="center"><font size="2"><b><font face="Arial, Helvetica, sans-serif">1*=Unacceptable&nbsp;&nbsp;2*=Poor&nbsp;&nbsp;3=Satisfactory&nbsp;&nbsp;4=Highly Satisfactory&nbsp;&nbsp;5=Outstanding&nbsp;&nbsp;UA=Unable to Assess<br></font></b><font face="Arial, Helvetica, sans-serif"><em>* Please include a written comment explaining scores of 1 or 2.<br>
        You are also welcome to include other comments that highlight exemplary behavior or situations where improvements should be made.</em></font></font></p>
        <%
            StuCount = 0
         %>
    </HeaderTemplate>
    <ItemTemplate>
    <%StuCount = StuCount + 1%>
    <table border="1" align="center" cellpadding="0">
        <tr>
            <td colspan="10" bgcolor="#FFFF99"><strong><font size="3" face="Arial, Helvetica, sans-serif"> <%#DataBinder.Eval(Container.DataItem, "StuFirstName")%> <%#DataBinder.Eval(Container.DataItem, "StuLastName")%></font></strong></td>
        </tr>
        <tr>
            <td width="30" bgcolor="#CCCCCC"><strong><font size="2" face="Arial, Helvetica, sans-serif">Area</font></strong></td>
            <td width="1" bgcolor="#CCCCCC"><strong><font size="2" face="Arial, Helvetica, sans-serif">Q</font></strong></td>
            <td width="25" bgcolor="#CCCCCC"><strong><font size="2" face="Arial, Helvetica, sans-serif">Low</font></strong></td>
            <td colspan="6" bgcolor="#CCCCCC"><strong><font size="2" face="Arial, Helvetica, sans-serif">Scale</font></strong></td>
            <td width="25" bgcolor="#CCCCCC"><strong><font size="2" face="Arial, Helvetica, sans-serif">High</font></strong></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">1</font></td>
            <td align="center" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">2</font></td>
            <td align="center" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">3</font></td>
            <td align="center" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">4</font></td>
            <td align="center" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">5</font></td>
            <td align="center" valign="top" bgcolor="#FFCCFF"><font size="2" face="Arial, Helvetica, sans-serif">UA</font></td>
            <td>&nbsp;</td>
        </tr>
        <input type="hidden" name="StuID<%=StuCount%>" value="<%#Eval("StuSchoolID")%>">
        <input type="hidden" name="StuLName<%=StuCount%>" value="<%#Eval("StuLastName")%>">
        <input type="hidden" name="StuFName<%=StuCount%>" value="<%#Eval("StuFirstName")%>">
        <% buildQuestions()%>
        <tr>
            <td colspan="10" align="left" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">Comments:<br></font>
            <textarea id="comment_<%=StuCount%>" name="Comments_<%=StuCount%>" cols="100" rows="3"></textarea></td>
        </tr>
        </table>
    </ItemTemplate>
    <FooterTemplate>
        <br />
        <div style="display:inline;"><center>
        <input type="hidden" name="Course" value="<%= Session("Course") %>">
        <input type="hidden" name="Year" value="<%= Session("Year") %>">
        <input type="hidden" name="Seq" value="<%= Session("Seq") %>">
        <input type="hidden" name="Track" value="<%= Session("Track") %>">
        <input type="button" name="Submit2" runat="server" onserverclick="SubmitEval" id="Submit2" value="Submit" class="cssbutton" />
        <input type="reset" name="Reset" value="Reset" class="cssbutton">
        </center></div>
    </FooterTemplate>
</asp:Repeater>

And the Js can be something like cannot be empty for now, I will add the rules later.

function validCheck(id) {
if(!document.getElementById(id))
    return false;

     if ((document.getElementById(id).value).length == 0) {
         alert("The textbox should not be empty");
         return false;
        }

}

Thank you, I am like 3 days into ASP.Net. I just need a way to pass the data from the generated forms into the javascript for validation, and since their ID is all generated, there isn't a hardcoded way to do so. So I am looking at Loop or something but my brain is fried atm.

Related posts

Recent Viewed