I've following login form which has two HTML5 text boxes with required valdation:
<div id="SignUpForm" class="loginContainer">
<div style="width: 100%; height: 20px">
<div class="triangle">
</div>
</div>
<table class="loginForm" align="left">
<tr>
<td align="left" class="style1">
<input id="txtCustEmailID" type="email" name="txtCustEmailID" placeholder="Enter Email ID"
required style="width: 195px" />
</td>
<td align="left">
<asp:Button ID="btnCustLogin" runat="server" Text="Sign Up" OnClick="btnCustLogin_Click" />
</td>
</tr>
<tr>
<td align="left" class="style1">
<input id="txtCustPwd" name="txtCustPwd" type="password" required placeholder="Enter Password"
style="width: 193px" />
</td>
<td align="left">
<input id="btnCancel" type="button" value="Cancel" onclick="cancel('txtCustEmailID','txtCustPwd','SignUpForm')" />
</td>
</tr>
<tr>
<td colspan="2" align="left" style="font-size: medium; color: #FFFFFF;">
<a href="#RegOnSrchdialog" name="modal" style="color: #FFFFFF; font-weight: bold"
onclick="EnableRegFormTxt('txtCustEmailID','txtCustPwd','SignUpForm')">Register</a>
</td>
</tr>
</table>
</div>
On clicking the anchor tag "Register" I am calling a javascript function EnableRegFormTxt which I am using to disable the login form textboxes so that their validations will also get disabled, but this js is not working and I am not able to do any post back on the page because of validations.
The js is:
function EnableRegFormTxt(i, j, k) {
document.getElementById("txtCustFName").disabled = false;
document.getElementById("txtCustLName").disabled = false;
document.getElementById("txtCustREmail").disabled = false;
document.getElementById("txtCustRPwd").disabled = false;
document.getElementById("txtCustRePwd").disabled = false;
document.getElementById("txtCustPh").disabled = false;
document.getElementById(i).disabled = true;
document.getElementById(j).disabled = true;
document.getElementById(k).style = "display:none";
}
Please let me know where I am wrong.
Thanx.
Hope this helps:
function makeReadOnly()
{
document.getElementById("TextBox1").readonly=true;
}
Call above function on click event or any other event you want.
Here is your function:
function EnableRegFormTxt(i, j, k) {
document.getElementById("txtCustFName").readonly = false;
document.getElementById("txtCustLName").readonly = false;
document.getElementById("txtCustREmail").readonly = false;
document.getElementById("txtCustRPwd").readonly = false;
document.getElementById("txtCustRePwd").readonly = false;
document.getElementById("txtCustPh").readonly = false;
document.getElementById(i).readonly = true;
document.getElementById(j).readonly = true;
document.getElementById(k).style = "display:none";
}
you can try this:
function DisableRegFormTxt(i, j, k) {
document.getElementById("txtCustFName").setAttribute('readonly');
document.getElementById("txtCustLName").setAttribute('readonly');
document.getElementById("txtCustREmail").setAttribute('readonly');
document.getElementById("txtCustRPwd").setAttribute('readonly');
document.getElementById("txtCustRePwd").setAttribute('readonly');
document.getElementById("txtCustPh").setAttribute('readonly');
}
function EnableRegFormTxt(i, j, k) {
document.getElementById("txtCustFName").removeAttribute('readonly');
document.getElementById("txtCustLName").removeAttribute('readonly');
document.getElementById("txtCustREmail").removeAttribute('readonly');
document.getElementById("txtCustRPwd").removeAttribute('readonly');
document.getElementById("txtCustRePwd").removeAttribute('readonly');
document.getElementById("txtCustPh").removeAttribute('readonly');
}
Related
I am getting an error message - Object reference not set to an instance of an object. I believe that 'files' is empty - but not sure why. Could someone tell me why files would be empty?
Thanks!
View:
<form type="multipart/form-data" action="#Url.Action("AddImage", "HelpDesk")" method="post">
<table cellpadding="0" cellspacing="0" style="width: 100%">
<tr>
<td style="width: 105px"><br /></td>
<td> </td>
</tr>
<tr>
<td style="width: 105px; font-weight: bold">Attach File(s):</td>
<td> </td>
</tr>
<tr>
<td>
<input type="hidden" id="id" name="id" value=#item.ID>
<input type="hidden" id="requesttype" name="RequestType" value=#item.RequestType>
<input type="file" id="files" name="files" multiple>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Add">
</td>
<td> </td>
</tr>
</table>
</form>
Controller:
public ActionResult AddImage(HelpdeskImage model, int id, string requesttype, HttpPostedFileBase[] files)
{
foreach (HttpPostedFileBase file in files)
{
var fileBytes = new byte[file.ContentLength];
file.InputStream.Read(fileBytes, 0, file.ContentLength);
hd.HelpdeskImages.Add(new HelpdeskImage
{
HelpdeskNum = id,
DocumentExt = Path.GetExtension(file.FileName),
Image = fileBytes,
DocumentName = System.IO.Path.GetFileName(file.FileName),
RequestType = requesttype,
Created = DateTime.Now,
}
);
hd.SaveChanges();
}
//}
return RedirectToAction("Details", new { id = id });
}
Modify your form tag to include enctype="multipart/form-data". Specifying this type is necessary when you have an input type="file".
<form enctype="multipart/form-data" action="#Url.Action("AddImage", "HelpDesk")" method="post">
...
</form>
I'm trying to edit data though angularjs and I've got all the data in view - but the only problem is that the dropdownlist does not select the value that is passed to it and I don't know why.
JS Code:
function getCustomer() {
var promiseGetStudent = SPACRUDService.getCustomer(ShareData.value);
promiseGetStudent.then(function (pl) {
pl.data.MirageDate = $filter('date')(pl.data.MirageDate, 'yyyy-MM-dd');
$scope.Cust = pl.data;
},
function (errorPl) {
$scope.error = 'failure loading Student', errorPl;
});
}
HTML Code:
<table class="table">
<td style="width:200px; text-align:center; vertical-align:central">إسم العميل</td>
<td>
<table class="table" style="margin-bottom: -3px;">
<tr>
<td style="padding:0; vertical-align:central; width:50%;">
<div class="input-group">
<span class="input-group-addon ion ion-person"></span>
<input type="text" class="form-control" placeholder="إسم العميل" ng-model="Cust.CustomerName">
</div>
</td>
<td style="width:125px; vertical-align:central" class="text-center">المدينة</td>
<td style="padding:0; vertical-align:central">
<input type="text" ng-model="Cust.CityID" name="cid" id="cid" />
#Html.DropDownList("CityID", null, "إختر المدينة", htmlAttributes: new { #class = "form-control", #style = "width=100%", #ng_model = "Cust.CityID" })
</td>
</tr>
</table>
</td>
</tr>
</table>
I get the value of "CityID" but the dropdownlist does not select it from the items, and when I look into html of the dropdownlist I found:
<option value="? number:2 ?"></option>
So please what is the problem here and how can I make it work?
I use jQuery for dialogbox. it's strange when I tried to delete some element on it. when I click ok button. diaolog box won't redirect even close itself. nothing happen.
this is my first content contained in dialogbox and it works.
<input type="button" class="ui-state-default ui-corner-all" id="indexbutton" onclick="book_tickets(this)" value="Book Seat" />
<div id="dialog" title="Time Limit">
<table>
<tr>
<td>Name</td>
<td>:</td>
<td><input type="text" id="txtName" value="" /></td>
</tr>
<tr>
<td> End of Time </td>
<td>:</td>
<td><input type="text" style="width: 100px;" id="timepicker_7" value="01:30 PM" /></td>
</tr>
</table>
</div>
when I tried to delete txtName, then OK button is not working or itsn't redirect to another page.
this is after I delete txtName element.
<table>
<tr>
<td> End of Time </td>
<td>:</td>
<td><input type="text" style="width: 100px;" id="timepicker_7" value="01:30 PM" /></td>
</tr>
</table>
this is how I write the dialogbox code
$(function () {
$("#dialog").dialog({
autoOpen: false,
width: 400,
buttons: [
{
text: "Ok",
click: function () {
ShowArrData(lObjSeat);
$(this).dialog("close");
}
},
{
text: "Cancel",
click: function () { $(this).dialog("close"); }
}
]
});
});
and this is my showobjdata function
function ShowArrData(o) {
for (var i = 0; i < o.length; i++) {
seatname = o[i].Name;
time = jQuery('#timepicker_7').val();
var guest = document.getElementById("txtName").value;
console.log(guest);
var sid = btnId;
if (sid == 'indexbutton') {
var url = "CheckSeat.aspx?noSeat=" + encodeURIComponent(lObjSeat[0].Name) + "&endtime=" + encodeURIComponent(time);
window.location.replace(url);
} else {
var url = "AdminCheckSeat.aspx?noSeat=" + encodeURIComponent(lObjSeat[0].Name) + "&endtime=" + encodeURIComponent(time) + "&guest=" + encodeURIComponent(guest);
window.location.replace(url);
}
}
}
my showobjdata flow is, if website accessed by index then go to checkseat.aspx else go to admin.
what's the matter ?
replace var guest = document.getElementById("txtName").value inside clause else
because I put it out of else, so when condition is guest=null then showarrdata is didn't do anything.
I basically have a web-browser control that is going through and automatically completing some forms, it's been a breeze so far, however I've gotten to a form that does not have the "submit " or "reset" button labelled with ID or Name. (I need to be able to click both) Example:
Submit Button
<td align="right" valign="middle" class="LeftSide" style="padding-right: 20; padding-top: 10;"><button class="Search" type="submit" tabindex="7"><b>Search</b></button></td>
Reset Button
<td align="left" valign="middle" class="RightSide" style="padding-left: 20; padding-top: 10;" colspan="2"><button class="Search" type="reset" tabindex="8"><b>Clear</b></button></td>
How would i search the HtmlDocument for these button's and click them? They're nested as the following:
<body><table><form><tr><td><button>'s
something like that, maybe ?
public void ClickButton(string type) {
var button = myWebBrowser.Document.GetElementsByTagName("button")
.Cast<HtmlElement>()
.FirstOrDefault(m => m.GetAttribute("type") == type);
if (button != null)
button.InvokeMember("click");
}
Usage
ClickButton("reset");
ClickButton("submit");
<td align="right" valign="middle" class="LeftSide" style="padding-right: 20; padding-top: 10;"><input type="submit" value="Submit" /></td>
<td align="left" valign="middle" class="RightSide" style="padding-left: 20; padding-top: 10;" colspan="2"><input type="reset" value="Reset" /></td>
HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement el in elc)
{
if (el.GetAttribute("type").Equals("submit"))
{
el.InvokeMember("click");
}
}
Why do popup does not work sometimes. There is no condition for popup. Whenever a button is clicked, it has to pop. Where do you guys think the problem might be??
Thanks,
<table id="pnlPopupAdditional" runat="server" style="display:none">
<tr>
<td>
<asp:Panel runat="server" CssClass="modalPopup">
<table width="350" height="80" class="warningPopup">
<tr>
<td>
<!-- <img src="images/warning_blue.gif" alt="Warning" /> -->
</td>
<td colspan="2" align="left" style="padding-left: 75px; padding-top: 10px;">
<asp:Literal ID="ltMessage" runat="server"></asp:Literal>
</td>
</tr>
<tr>
<td align="center" colspan="4">
<input id="btnYesAdditional" type="button" value="YES" class="popupButton" />
<input id="btnNoAdditional" type="button" value="NO" class="popupButton" />
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
<asp:Button ID="btn" runat="server" Visible="false" />
private void SetAdditionalLocationMessage()
{
_AccountSummary accountSummary = new _AccountSummary();
accountSummary = new Merchant2().GetAccountSummary(MerchantID);
if (accountSummary != null)
{
if (accountSummary.PackageID != (int)CommonHelper.Package.Free )
btnAdd.Visible = true;
else
btnAdd.Visible = false;
}
if (new Merchant2().IsLocationCountExceed(MerchantID))
{
string locationFee = new Merchant2().GetAdditionalLocationFee(accountSummary.PackageID).ToString();
ltMessage.Text = String.Format(ApplicationData.MSG_ADDITIONAL_LOCATION_CHARGE, locationFee);
ModalPopupExtender1.TargetControlID = "btnAdd";
ConfirmButtonExtender1.TargetControlID = "btnAdd";
}
else
{
ModalPopupExtender1.TargetControlID = "btn";
ConfirmButtonExtender1.TargetControlID = "btn";
}
//Controls_UC
protected void btnAdd_Click(object sender, ImageClickEventArgs e)
{
MerchantID = CommonHelper.GetLoggedInMerchant();
string QueryString = ApplicationData.URL_MERCHANT_COMPANY_PAYMENT + "?MerchantProfilePages";
Response.Redirect(QueryString);
It may be a result of JavaScript referenced DOM elements being disposed of during an AJAX request.
This is assuming you are acquiring a JavaScript reference of the DOM element referenced via pnlPopupAdditional.ClientID, so that you may modify the display:none; style declaration.