The newly created web part is working fine on local server but after deployed on the another server it is not working.Mainly the request is not going to the server when clicked on the submit button.
HTML code:
<div class="form-group">
<div class="col-lg-offset-3 col-md-offset-3 col-sm-offset-3 col-lg-9 col-md-9 col-sm-9 col-xs-12">
<asp:Button ID="btnEditWI" class="btn btn-custom" runat="server" Text="Submit" OnClick="EditWIUpload_Click" ValidationGroup="submitEdit"/>
<input id="cancelEditWI" type="button" value="Cancel" class="btn btn-custom" name="Cancel" data-dismiss="modal" CausesValidation="false" />
</div>
</div>
Server side code:
protected void EditWIUpload_Click(object sender, EventArgs e)
{
bool isValidate = validateForm();
bool isCheckListIdExists = checkListExists();
if (isValidate)
{
try
{
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
if (fuWorkInstruction.HasFile)
{
SPDocumentLibrary documentLib = web.Lists["WorkInstruction"] as SPDocumentLibrary;
SPFileCollection files = documentLib.RootFolder.Files;
SPListItem chkItem = documentLib.GetItemById(strCheckListID);
string strChkId = chkItem["WorkInstructionID"].ToString();
chkItem.Delete();
Stream fStream = fuWorkInstruction.PostedFile.InputStream;
byte[] _byteArray = new byte[fStream.Length];
fStream.Read(_byteArray, 0, (int)fStream.Length);
fStream.Close();
web.AllowUnsafeUpdates = true;
Random rnd = new Random();
int fileRnd = rnd.Next(1000);
string fileExt = Path.GetExtension(fuWorkInstruction.PostedFile.FileName);
string fileName = Path.GetFileNameWithoutExtension(fuWorkInstruction.PostedFile.FileName) + fileRnd;
string _fileUrl = fileName + fileExt;
//string _fileUrl = documentLib.RootFolder.Url + "//" + fuWorkInstruction.PostedFile.FileName;
//string _fileUrl = Path.GetFileName(fuWorkInstruction.PostedFile.FileName);
bool IsOverwriteFile = true;
//SPFile file = documentLib.RootFolder.Files.Add(_fileUrl, _byteArray, IsOverwriteFile);
SPFile newFile = files.Add(documentLib.RootFolder.Url + "/" + _fileUrl, _byteArray, IsOverwriteFile);
SPList documentLibraryAsList = web.Lists["WorkInstruction"];
SPListItem item = documentLibraryAsList.GetItemById(newFile.ListItemAllFields.ID);
if (isCheckListIdExists)
{
item["WorkInstructionID"] = strChkId;
}
else
{
item["WorkInstructionID"] = txtID.Text;
}
item["Revision"] = txtRevision.Text;
item["Description"] = txtDescription.Text;
item["WorkRecordID"] = new SPFieldLookupValue(workRecId);
item.Update();
//newFile.CheckIn("New", SPCheckinType.OverwriteCheckIn);
web.AllowUnsafeUpdates = false;
}
else
{
web.AllowUnsafeUpdates = true;
SPDocumentLibrary documentLib = web.Lists["WorkInstruction"] as SPDocumentLibrary;
SPListItem item = documentLib.GetItemById(strCheckListID);
if (isCheckListIdExists)
{
item["WorkInstructionID"] = item["WorkInstructionID"].ToString();
}
else
{
item["WorkInstructionID"] = txtID.Text;
}
item["Revision"] = txtRevision.Text;
item["Description"] = txtDescription.Text;
item["WorkRecordID"] = new SPFieldLookupValue(workRecId);
item.Update();
web.AllowUnsafeUpdates = false;
}
});
}
}
}
catch (Exception ex)
{
txtDescription.Text = ex.StackTrace.ToString();
}
txtID.Text = "";
txtRevision.Text = "";
txtDescription.Text = "";
}
}