首页 > 编程 > .NET > 正文

asp.net开发随笔

2024-07-10 13:12:06
字体:
来源:转载
供稿:网友

1.在asp.net页面上,执行jsp(1),在pageload中,添加.attributes.add

    this.imgselectbatchid.attributes.add("onclick","selectswatchcheckbill(ctlproductid,ctlnofitycom,ctlcheckbillid,ctlselbatchid);");

对应的 jsp过程

function selectswatchcheckbill(productid,companyid,incheckbillid,batchid)
{
 para=productid.value
 para1=companyid.value
 var obj = new object();
 obj.var1=batchid;
 obj.var2=incheckbillid; 
 window.showmodaldialog('../selectforms/selectframe.aspx?url='../selectforms/sglselectswatch.aspx&type='+para+'&companyid='+para1,obj,
 'dialogheight=580px;dialogwidth=700px;status=no;edge=raised;scroll=no'); 
}

aspx的代码页,取得查询参数

  private string type
  {
   get
   {
    if (viewstate["type"] != null)
     return viewstate["type"].tostring();
    else
     return "";
   }
   set
   {
    viewstate["type"] = value;
   }
  }

  private string companyid
  {
   get
   {
    if (viewstate["companyid"] != null)
     return viewstate["companyid"].tostring();
    else
     return "";
   }
   set
   {
    viewstate["companyid"] = value;
   }
  }

  private void page_load(object sender, system.eventargs e)
  {
   if (!ispostback)
   {
    try
    {
     type = request.querystring["type"].tostring();
     companyid = request.querystring["companyid"].tostring();
    }
    catch
    {}
   }
  }

2.在asp/asp.net页面加载时,执行js过程

<script language="javascript">
function populatedata()
{
}   
</script> <body ms_positioning="gridlayout" background="../../../images/mailuserbg.gif">

<script language="javascript">
function setcookie(sname, svalue)
{
 document.cookie = sname + "=" + escape(svalue) + "; ";
}
</script>
<body onload='setinterval("re()",(getcookie("uds_refreshtime"))==null?30000:getcookie("uds_refreshtime"))'>

<body onload='javascript: if(this.document.all.txtusername.value=="") this.document.all.txtusername.focus();else this.document.all.txtpassword.focus();'>


<body >

<body >

<body query_string"].tostring() %>', '', 'toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');close();">

3.asp.net页面中,服务器控件对js过程的执行(2)

  <script language="javascript">
   function selquerybatchex(para,para1,para1,para2,para3,para4,para5)
   {
    var rtnval = window.showmodaldialog('../../selectform/selectquerybatch.aspx?opener=' + para+'&b='+para1+'&c='+para2+'&d='+para3+'&e='+para4+'&f='+para5,'','dialogwidth=600px;dialogheight=400px;status=no;edge=raised;scroll=no');
    if(rtnval != null)
    {
     if(rtnval.val2 == 'ok')
     {
      para.value = rtnval.val1;
      document.forms[0].elements['txtbatch'].value=rtnval.val1;
      
     }
    }
   }
   

//以下过程和,在pageload中,用imgselbatch.attributes.add 等效

//    this.imgselbatch.attributes.add("onclick","selquerybatchex('txtbatch','txta','txta','txta','txta','txta');");
    function selectbatch(e)
    {
    if(event.srcelement.id=="imgselbatch")
    {
     return selquerybatchex('txtbatch','txta','txta','txta','txta','txta');
    }
    }
    document.onclick = selectbatch;
    
  </script>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表