不知道你的用户控件在什么位置,是放在界面上的还是在代码里加的,页面显示完后IsPostBack就是true了,除非你再次用刷新,否则响应控件的事件的话IsPostBack就会是true
解决方案 »
- 使用UrlRewritingNet发布后,无法找到该页的问题
- gridview组件和数据都不能在页面显示是怎么回事,这是我的代码,大神们帮帮忙啊
- 请教如何才能把数据表中的两个字段值赋给dropdownlist的DataTextField?
- 急救:如何遍历页面上所有TextBox的文本,然后调用一个将信息插入数据库的方法就循环插入数据库中?具体请看里面。
- 数据库中时间是datatime类型,2006-03-15 22:22:22 这样的 我现在要查询所有日期是2006-03-15 的记录,sql怎么写?
- 买了ASP.NET办公自动化系统开发实例导航(VB.NET)这本书的进来
- 想建个手机网站有人帮忙下吗
- asp.net 站点每天千万次访问解决方案
- 求助:页面刷新和重定向
- 菜鸟的一个巨难问题:一个从数据库里读出来的巨长的字符串,显示满一屏时怎样让他自动分页呢?
- 求VSS使用方法和例子!
- 关于局域网内ip的问题
this.IsPostBack指的同一个页面;这两个都是正确的
{
数据链接,
绑定
}
谢谢两位,我页面里面,GridView编辑状态里有一个用户自定义DropDownList,想首次加载时绑定DropDownList的内容,不知道怎么实现?
-------------------------------------------------
放在if(!IsPostBack)
{
load your DropDownList Data
}
--------------------------------------------------------
前台JS//增加控件
function addClientControls()
{
var count_obj;
var tr_obj;
var td_obj;
var file_obj;
var form_obj;
var count;
var table_obj;
var button_obj;
var countview_obj;
var str1;
var str2;
form_obj=document.getElementById("Form1");
fj_obj=document.getElementById("td_fj");
if(fj_obj.innertext=="无附件")
{
fj_obj.innertext="";
}
count_obj=document.getElementById("count_obj"); if (count_obj==null)
{
count_obj=document.createElement("input");
count_obj.type="hidden";
count_obj.id="count_obj";
count_obj.value=1;
form_obj.appendChild(count_obj);
count=1;
count_obj.value=1;
}
else
{
count_obj=document.getElementById("count_obj");
count=Number(count_obj.value)+1;
count_obj.value=count;
}
div_obj=document.createElement("div");
div_obj.id="div_" + count;
div_obj.align="center";
fj_obj.appendChild(div_obj);
str1="附件名称:<input type='file' name='fj"+count+"' size=55 class='input' id=fj"+count+">";
str2="<br>附件标题:<input type='text' name='fjsm"+count+"' class='input' size=55 maxlength=100 id='fjsm"+count+"'>";
str3="<input type='button' class='button' value='删除本条' onclick=javascript:delClientControls("+"\""+div_obj.id+"\""+"); id='button"+count+"' name='button"+count+"'>";
div_obj.innerHTML=str1+str2+str3;
}//删除控件
function delClientControls(id)
{
var child;
var parent;
var count_obj; child=document.getElementById(id);
count_obj=document.getElementById("count_obj");
if(child==null)
{
alert("对象为空");
}
else
{
child.removeNode(true)
count_obj.value=Number(count_obj.value)-1;
if(count_obj.value=="0")
{
count_obj.removeNode(true);
}
} parent=document.getElementById("td_fj");
if(!parent.hasChildNodes)
{
parent.innerText="";
}
}
-----------------------------------------------------------
aspx file
----------------------------
<tr class="InputFrameButtonLine">
<td align="center"><input class="button" onclick="addClientControls()" type="button" value="新增附件" name="button_xzfj">
<INPUT class="button" id="button3" onclick="postClientCheck()" type="button" value="保存">
<input class="button" id="button2" onclick="javascript:history.back(0)" type="button" value="返回"
name="button2">
</td>
<P><asp:label id="strStatus" runat="server" Width="500px" Font-Names="宋体" Font-Bold="True" Font-Size="9pt"
BorderStyle="None" BorderColor="White"></asp:label></P>
</tr>
----------------------------------------------------------------------------------
后台获取并写入数据库:
-------------------
#region 上传新附件
ArrayList al =new ArrayList();
for(int i = 0;i<Request.Form.Count;i++)
{
if(Request.Form.Keys[i].ToString().Length>4)
{
if(Request.Form.Keys[i].ToString().Substring(0,4)=="fjsm")
{
al.Add(Request.Form[i].ToString());
}
}
} ///'遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files; /// '状态信息
System.Text.StringBuilder strMsg = new System.Text.StringBuilder();
string fileName,fileSearchName, fileExtension,strFJXH1,strFJBT1,strDirectory,strSearchDirectory;
try
{
for(int iFile = 0; iFile < files.Count; iFile++)
{
///'检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
fileName = System.IO.Path.GetFileName(postedFile.FileName);
fileSearchName=fileName; fileExtension = System.IO.Path.GetExtension(fileName);
strFJXH1 =(new AppDataCMP.DocumentManageCMP()).GetNewID("OA_DA_FJ","FJXH").ToString();
fileName="gxb_"+SystemManage.SystemUserManage.GetUserID(Session).ToString()+"_"+strFJXH1+fileExtension;
fileSearchName=fileSearchName.Replace(fileExtension,"")+"["+strFJXH1+"]"+fileExtension;
//生成目录
strDirectory=(new AppDataCMP.DocumentManageCMP()).GetDocumentAtthfilesUpLoadDirectory(System.Web.HttpContext.Current.Request.MapPath("DocumentAtthfiles/"));
strSearchDirectory=(new AppDataCMP.DocumentManageCMP()).GetDocumentSearchUpLoadDirectory(System.Configuration.ConfigurationSettings.AppSettings["FilePath"],this.txtFBFL.Text+@"\");
//寻找附件标题
strFJBT1=al[iFile].ToString();
//增加到数据库
SortedList temp = new SortedList(); temp.Add("FJXH",strFJXH1);
temp.Add("DAXH",this.txtDAXH.Text);
temp.Add("FJBT",strFJBT1);
temp.Add("CDLJ","documentatthfiles"+@"/"+strDirectory.Substring(strDirectory.Length-8,8)+@"/"+fileName);
//temp.Add("CCGS",null)
//temp.Add("XJCX",null);
AppDataCMP.DocumentManageCMP dm = new AppDataCMP.DocumentManageCMP();
dm.Open();
dm.AddNewDocumentAtthfiles(temp);
dm.Close();
//上传附件
postedFile.SaveAs(strDirectory +@"\"+ fileName);
postedFile.SaveAs(strSearchDirectory+@"\"+ fileSearchName);
}
}
catch(System.Exception Ex)
{
strStatus.Text = Ex.Message;
}
就是用上面的js增加控件
用Request.Form获取表单提交的东西。
-------------------------------------
老大,是你叫我们写程序重在思想的吧?如果你非要给楼主答案,你可以将上面的代码套用一下就行了。
jf!!
其实至于楼上那样的回复,一般我都不会多事。我相信那纯粹是随便仍一句某个牛人说过“此句时髦”的话而已,并没有结合楼主的问题。