将Guid值分配给C#变量,即字符串

时间:2015-09-15 07:34:47

标签: c# guid asp.net-3.5

我正在尝试捕获GUID值并存储在字符串变量中但获取空值

模型

public string StudentRemediationSignatureCheckGuid { get; set; }

ContextSession给我GUID值,我想将其分配给上面的变量

_assessmentRemidationObject.StudentRemediationSignatureCheckGuid = ContextSession.GUID.ToString(); 

更新代码

  public string SeniorAssessorGuid = string.Empty; //global variable


 protected void checkBoxSeniorAssessorSignature_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox SelectedCheckBoxObject4 = (CheckBox)sender;

        if (SelectedCheckBoxObject4.Checked)
        {

            TxtBoxSeniorAssessorSignatureDate.Text = System.DateTime.Now.ToString("d/M/yyyy");

            _assessmentRemidationObject.SeniorAssessorSignatureCheckGuid = ContextSession.GUID.ToString(); 
            SeniorAssessorGuid = ContextSession.GUID.ToString(); 
        }
        else if (!SelectedCheckBoxObject4.Checked)
        {
            TxtBoxSeniorAssessorSignatureDate.Text = string.Empty;

        }
    }

1 个答案:

答案 0 :(得分:1)

如果您丢失其值,请不要将ContextSession.GUID的值存储在您网页_assessmentRemidationObject的成员中。您需要使用全局变量或持久存储(例如数据库)。在阅读之前,请尝试找到重置_assessmentRemidationObject的位置。