<form runat= "Server" id= "MyForm" > <table> <tr> <td align= "right" > Unit name:</td> <td
Align= "Left" > <asp:textbox id= "txtname" runat= "Server" width= "150px" ></asp:TextBox> </td> <td > Type:</td> <td align= "left" > <asp:dropdownlist id= "Ddltype" runat=
"Server" width= "150px" > <asp:listitem value= "true" selected= "true" > Text link </asp:ListItem> <asp:listitem value= "false" > Photo links </asp:ListItem> </asp:DropDownList>
;/td> </tr> <tr> <td align= "right" > Unit type:</td> <td align= "left" > <asp:dropdownlist id= "Ddlcooperatetype" runat= "Server" width= "150px" > <asp:listitem value=
"0" > University </asp:ListItem> <asp:listitem value= "1" selected= "True" > Enterprise </asp:ListItem> </asp:dropdowNlist> </td> <td > ordered:</td> <td align= "left" > <asp:textbox id= "
Txtsort "runat=" Server "width=" 150px "text=" 0 "></asp:TextBox> </td> </tr> <tr> <TD > Links:</td> <td align= "left" > <asp:textbox id= "txtlink" runat= "Server" Heig ht= "17px" width= "150px" text= "http://www.qk12333.com" ></asp:TextBox> <as P:regularexpressionvalidator id= "RegularExpressionValidator1" runat= "Server" Controltovalidat E= "Txtlink" errormessage= is not in the correct format. "Forecolor=" Red "validationexpression=" http (s)?:/ /([\w-]+\.) +[\w-]+ (/[\w-/?%&=]*)? " ></asp:RegularExpressionValidator> </td> <td > Image upload:</td> <td align= "left" > <asp:fileupload id= "fileupimage" runat= "Server" width= "244px"/> </td> </tr> <tr> <td align=" right "> Related description:</td> <TD align= "left" colspan= "3" > <asp:textbox id= "txtdesc" runat= "Server" textmode= "MultiLine" width= "60 0 "height=" 128 "></asp:TextBox> </td> </tr> <tr> <td colspan = "4" align= "center" > <asp:button id= "btnfriendlink" runat= "Server" text= "Submit" Oncl
ick= "Btnfriendlink_click"/> <asp:button id= "Btnrestfriendlink" runat= "Server" text= "reset" onclick= "Btnrestfriendlink_click"/> </td> </tr> </table> </form>
protected void Btnfriendlink_click (object sender, EventArgs e) {if (txtName.Text = "" | | txtName.Text = = null) {this. Clientscript.registerstartupscript (this. GetType (), "", "<script>alert (' unit name cannot be empty.
');</script> ");
Return } string message = String.
Empty; String imagesrc = String.
Empty; Picture link, need to upload if (Ddltype.selectedvalue = = "false" | | (fileupimage.filename!=null&&fileupimage.filename!=string. Empty)) {string imagename = DateTime.Now.ToFileTime ().
ToString (); if (imagename = = "" | | ImageName = = null) {this. Clientscript.registerstartupscript (this. GetType (), "" "," <script>alert (' please select a picture.
') </script> ");
Return
String contentType = Imagename.substring (Imagename.lastindexof (".") + 1); String folderpath = Server.MapPath ("..
/uploadfile/friendlink/"); If (!
Directory.Exists (FolderPath)) {directory.createdirectory (FolderPath); String path = Server.MapPath ("...").
/uploadfile/friendlink/") + imagename; IMAGESRC = "uploadfile/friendlink/" + imagename + "." + fileUpImage.FileName.Substring (
FileUpImage.FileName.LastIndexOf (".") + 1);;
Uploadfile.upload (fileupimage, path, ref message);
} Friendslink upimage = Inserttofriendslink (IMAGESRC); if (upimage = = null) {this. Clientscript.registerstartupscript (this. GetType (), "", "<script>alert (' Add failed.
') </script> ");
Return
else {reset (); This. Clientscript.registerstartupscript (this. GetType (), "", "<script>alert (' Add success.
') </script> "); } Private Friendslink Inserttofriendslink (string imagesrc) {Friendslink Friendslink = new Frie
Ndslink (); Friendslink.
Name = Stringsub.subtitle (txtName.Text);
Friendslink.link = Txtlink.text;
Friendslink.desc = Stringsub.subdescription (TxtDesc.Text.Trim ());
FRIENDSLINK.IMAGESRC = IMAGESRC;
Friendslink.sortid = Convert.ToInt32 (Txtsort.text);
Friendslink.cooperatetype = Convert.ToInt32 (Ddlcooperatetype.selectedvalue);
Friendslink.linktype = Convert.toboolean (Ddltype.selectedvalue);
Return Friendslinkmanager.addfriendslink (Friendslink); }