コード例 #1
0
    protected void tplGrid_SelectedIndexChanged(object sender, EventArgs e)
    {
        string packageId = tplGrid.SelectedItem.Cells[5].Text;

        if (string.IsNullOrEmpty(packageId) || packageId.IndexOfAny(new char[] { '/', '\\', ':' }) >= 0)         //Don't allow path control elements in a package ID.
        {
            MessageBox.Show("Invalid template path");
            return;
        }

        if (!PackageCache.PackageExists(packageId))
        {
            MessageBox.Show("The selected template could not be found. Please contact your Sample Portal site administrator for assistance.");
            return;
        }

        //Open a new work session.
        try
        {
            // title is in Cells[2].
            string templateTitle = tplGrid.SelectedItem.Cells[2].Text;
            _session = Factory.CreateWorkSession(Session, packageId, templateTitle);

            // Make sure that there is a cache for the assembled documents, and that it is empty.
            AssembledDocsCache cache = Factory.GetAssembledDocsCache(this.Session);
            cache.Clear();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            return;
        }

        //Redirect to "select answer set" page
        Response.Redirect("SelAns.aspx");
    }