Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
script var can just run once?
posted

 i define a client script for define the 2 cell value when i edit another cell,the value is came from the fuction name getPCode,it genearate a unique value in the table,here is the code :

 <script type="text/javascript" language="javascript">
        function BeforeEnterEditMode(gridName,cellID,newValue)
        {
              //get the cell
              var cell = igtbl_getCellById(cellID);
              var value1 = cell.Row.getCell(0).getValue();
              var sessionID = "<%=getSession() %>";
              var dcode = "<%=getPCode() %>";

                if (value1 == null)
                {
                    cell.Row.getCell(0).setValue(sessionID);
                    sessionID = null;
                    cell.Row.getCell(1).setValue(dcode);
                    dcode = null;
                    cell.endEdit();
                }
                else {
                    cell.Row.getCell(1).setValue("789");
                }
                return 0;
        }
    </script> 

 

i define the fuction getPCode in my .cs file ,as this :

   protected string getPCode()
    {
        string PCode = string.Empty;
        //do some thing in db
        return PCode;
    } 

 

i  track the source code and find this getPCode() only one time,when i add a new empty row,the dcode value is the last value because the fuction getPCode() don't run,so can anybody tell me why?

Parents
No Data
Reply
  • 28464
    posted

    Hello,

    I am not sure I understand the whole scenario in details. What I can tell however is that var dcode = "<%=getPCode() %>"; is executed only once, at compile time and not each time it is accessed (<%= ... %> is just a shortcut for the ASP classic print), so maybe this interferes with the logic in some way?

Children