I'm trying to load a hover page over the current default page. So far the hover pop up window fads in but then in fades out right away. I’m not sure what I’m doing wrong below. Any help would be appreciated.
Js File
var popupStatus = 0;
//loading popup with jQuery magic!
function loadPopup(){
//loads popup only if it is disabled
if(popupStatus==0){
$("#backgroundPopup").css({
"opacity": "0.7"
});
$("#backgroundPopup").fadeIn("slow");
$("#popupContact").fadeIn("slow");
popupStatus = 1;
}
}
//disabling popup with jQuery magic!
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popupContact").fadeOut("slow");
popupStatus = 0;
}
}
//centering popup
function centerPopup(){
//request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#popupContact").height();
var popupWidth = $("#popupContact").width();
//centering
$("#popupContact").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
});
//only need force for IE6
$("#backgroundPopup").css({
"height": windowHeight
});
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
//LOADING POPUP
//Click the button event!
$("#button").click(function(){
//centering with css
centerPopup();
//load popup
loadPopup();
});
//CLOSING POPUP
//Click the x event!
$("#popupContactClose").click(function(){
disablePopup();
});
//Click out event!
$("#backgroundPopup").click(function(){
disablePopup();
});
//Press Escape event!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
}
});
});
aspx page
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<center>
<img src="Pictures/6.jpg" alt="my image des" />
<div id="button">
<input type="submit" value="Press me please!" /></div>
</center>
<div id="popupContact">
<a id="popupContactClose">x</a>
<p id="contactArea">
Rules:
1) Items with "*" are required fields to be filled out.
<br />
</p>
<asp:Label ID="lblEmail" runat="server" Text="*Your Email: "></asp:Label><asp:TextBox
ID="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="You must enter your email address."></asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblUserName" runat="server" Text="*Name: "></asp:Label>
<asp:TextBox ID="txtName" runat="server" Width="157px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtName"
ErrorMessage="You must enter a username."></asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblCity" runat="server" Text="*City: "></asp:Label>
<asp:TextBox ID="txtCity" runat="server" Width="168px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtCity"
ErrorMessage="You must enter your location."></asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblState" runat="server" Text=" State: "></asp:Label>
<asp:TextBox ID="txtState" runat="server" Width="168px"></asp:TextBox><br />
<asp:Label ID="lblAge" runat="server" Text="*Age: "></asp:Label>
<asp:TextBox ID="txtAge" runat="server" Width="165px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtAge"
ErrorMessage="Please enter your age to continue."></asp:RequiredFieldValidator>
<br />
<asp:Label ID="lblSex" runat="server" Text="*Gender: "></asp:Label>
<asp:RadioButton ID="rdMale" runat="server" GroupName="Gender" Text="Male" />
<asp:RadioButton ID="rdFemale" runat="server" GroupName="Gender" Text="Female" />
<asp:Label ID="RadialLBL" runat="server"></asp:Label>
<br />
<br />
<asp:Label ID="lblYahoo" runat="server" Text="Yahoo ID: "></asp:Label>
<asp:TextBox ID="YahooID" runat="server"></asp:TextBox>
<br />
<asp:Label ID="lblMSN" runat="server" Text="MSN ID: "></asp:Label>
<asp:TextBox ID="MSNID" runat="server" Width="133px"></asp:TextBox>
<br />
<br />
<asp:Label ID="lblMyspaceLink" runat="server" Text="Your Myspace Link: "></asp:Label>
<asp:TextBox ID="MyspaceLink" runat="server" Width="255px"></asp:TextBox>
<br />
<asp:Label ID="lblFaceBookLink" runat="server" Text="Your FaceBook Link: "></asp:Label>
<asp:TextBox ID="FaceBooklink" runat="server" Width="244px"></asp:TextBox>
<br />
<asp:Label ID="lblUploadpic" runat="server" Text="*Upload your picture."></asp:Label>
<asp:FileUpload ID="FileUpload1" runat="server" Height="22px" Width="217px" /><br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label><br />
<br />
<asp:Label ID="lblDesctiption" runat="server" Text="*User Bio: "></asp:Label><br />
<asp:TextBox ID="txtDescription" runat="server" MaxLength="240" Width="390px" Height="73px"
Rows="3" TextMode="MultiLine"></asp:TextBox><br />
<br />
<asp:Button ID="btnRegister" runat="server" Text="Register" OnClick="btnRegister_Click" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtDescription"
ErrorMessage="Enter a bio or description of yourself."></asp:RequiredFieldValidator>
<br />
<asp:Label ID="EnterAll" runat="server"></asp:Label>
<asp:Label ID="Displayme" runat="server" Text=""></asp:Label>
<br />
<br />
</div>
<div id="backgroundPopup">
</div>
A good first step is to ensure that your click events are being properly handled to prevent unwanted bubbling. You can do this with each of the click handling functions:
$("#button").click(function(e){
e.preventDefault();
//centering with css
centerPopup();
//load popup
loadPopup();
});
That may cause the problem to stop happening, and even if it doesn't, it's a good idea to prevent weird behavior from happening in the future. You can read more about preventDefault here: http://api.jquery.com/event.preventDefault/
Related
I'm trying to force the user to choose to fill either the Photo or the Video Textbox using the CustomValidator but it's not working, I've tried searching around and from previous questions a lot of people instructed to add the ValidateEmptyText="true" property, I tried adding it but it still won't fire.
I'm using other RequiredFieldValidators which are operating normally.
This is my aspx code of the two fields:
<asp:Button ID="btn1" runat="server" Text="+"/>
<asp:TextBox runat="server" PlaceHolder="Photos" ID="pics" ValidationGroup="txt1"></asp:TextBox>
<br />
<asp:Button ID="btn2" runat="server" Text="+"/>
<asp:TextBox ID="vids" runat="server" PlaceHolder="Videos" ValidationGroup="txt1"></asp:TextBox>
<asp:CustomValidator runat="server" ErrorMessage="Please enter either a photo or a picture!" OnServerValidate="ValidateBoxes" ValidationGroup="txt1" ValidateEmptyText="true"></asp:CustomValidator>
This is my c# Validation method:
public void ValidateBoxes(object sender, ServerValidateEventArgs e)
{
if (string.IsNullOrEmpty(pics.Text) && string.IsNullOrWhiteSpace(vids.Text))
e.IsValid = false;
else
e.IsValid = true;
}
EDIT : This is one of the text boxes and it's validators from the output screen shots.
<asp:TextBox ID ="city_in" PlaceHolder ="Enter city" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="city_in" ErrorMessage="Please enter the city!" ForeColor="Red"></asp:RequiredFieldValidator>
EDIT: This is the whole aspx Code:
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<h1>
Creating An Event
</h1>
<br />
<h3>
Please Provide the information below
</h3>
<asp:TextBox ID ="city_in" PlaceHolder ="Enter city" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="city_in" ErrorMessage="Please enter the city!" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID="date" runat="server" PlaceHolder ="Enter date" TextMode="Date" ></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="date" ErrorMessage="Please enter the date!" ForeColor="Red" ></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID="desc" runat="server" PlaceHolder = "Description"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="desc" ErrorMessage="Please enter the description!" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID ="entertain" runat="server" PlaceHolder ="Entertainer"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="entertain" ErrorMessage="Please enter the entertainer!" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID ="viewer" runat="server" PlaceHolder ="ID"></asp:TextBox>
<br />
<br />
<asp:TextBox ID ="location" runat="server" PlaceHolder ="Location"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ErrorMessage="Please enter the location!" ControlToValidate="location" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<p>
Please choose what type of Multimedia you would like to upload
</p>
<br />
<asp:Button ID="btn1" runat="server" Text="+"/>
<asp:TextBox runat="server" PlaceHolder="Photos" ID="pics" ></asp:TextBox>
<br />
<asp:Button ID="btn2" runat="server" Text="+"/>
<asp:TextBox ID="vids" runat="server" PlaceHolder="Videos"></asp:TextBox>
<asp:CustomValidator runat="server" ErrorMessage="Please enter either a photo or a picture!" OnServerValidate="ValidateBoxes" ValidateEmptyText="true"></asp:CustomValidator>
<br />
<br />
<asp:Button ID ="btn" runat="server" Text="Create Event" OnClick="create_Event" />
<asp:Button runat="server" Text="Cancel" OnClick="go_Profile"/>
Output:
This code was tested and works properly.
<body>
<form id="form1" runat="server">
<p>
Please choose what type of Multimedia you would like to upload
</p>
<br />
<asp:TextBox runat="server" PlaceHolder="Photos" ID="pics"></asp:TextBox>
<br />
<asp:TextBox ID="vids" runat="server" PlaceHolder="Videos"></asp:TextBox>
<asp:CustomValidator runat="server" ErrorMessage="Please enter either a photo or a picture!" OnServerValidate="ValidateBoxes" ValidateEmptyText="true"></asp:CustomValidator>
<br />
<br />
<asp:Button ID="btn" runat="server" Text="Create Event" />
<asp:Button runat="server" Text="Cancel" />
</form>
</body>
with this code:
public void ValidateBoxes(object sender, ServerValidateEventArgs e)
{
if (string.IsNullOrEmpty(pics.Text) && string.IsNullOrWhiteSpace(vids.Text))
e.IsValid = false;
else
e.IsValid = true;
}
if I enter any value in either of the two textboxes, the Validator is not shown.
I wanted to leave a comment but figured it would be best to display to you exactly what I tested this way you know what is working.
You have to make sure the Page IsValid before creating your event...
protected void btn_Click(object sender, EventArgs e)
{
if (IsValid)
{
Response.Write("Creating an event");
}
}
I am stuck on passing values from a form on one page to (confirm.aspx) another page. Would someone help me out with this? I am not looking for some one to code my program because I have done much of the work already. Here is what I have, Default.aspx as three values that I need to pass to Confirm.aspx. This is what I have for the Default.aspx.
<form id="form1" runat="server">
<h1>Price quotation</h1>
<label>Sales price</label>
<asp:TextBox ID="txtSalesPrice" runat="server" CssClass="entry">100</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtSalesPrice" Display="Dynamic" ErrorMessage="RequiredFieldValidator" CssClass="validator">Required</asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txtSalesPrice" Display="Dynamic" MaximumValue="1000" MinimumValue="10" Type="Double" CssClass="validator">Must be from 10 to 1000</asp:RangeValidator><br /><br />
<label>Discount percent</label>
<asp:TextBox ID="txtDiscountPercent" runat="server" CssClass="entry">20</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDiscountPercent" Display="Dynamic" ErrorMessage="RequiredFieldValidator" CssClass="validator">Required</asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="txtDiscountPercent" Display="Dynamic" MaximumValue="50" MinimumValue="10" Type="Double" CssClass="validator">Must be from 10 to 50</asp:RangeValidator><br />
<label>Discount amount</label>
<asp:Label ID="lblDiscountAmount" runat="server" CssClass="result" ></asp:Label><br /><br />
<label>Total price</label>
<asp:Label ID="lblTotalPrice" runat="server" CssClass="result" ></asp:Label><br /><br />
<asp:Button ID="btnCalculate" runat="server" Text="Calculate" OnClick="btnCalculate_Click" CssClass="button" />
<asp:Button ID="ConfirmButton" runat="server" CssClass="button" Text="Confirm" PostBackUrl="~/Confirm.aspx" OnClick="ConfirmButton_Click" />
<p><asp:Label ID="lblMessage" runat="server" EnableViewState="false" /></p>
</form>
Code Behind the Default.aspx
protected void ConfirmButton_Click(object sender, EventArgs e)
{
Session["Sales"] = txtSalesPrice.Text;
Response.Redirect("Confirm.aspx");
Session["Amt"] = lblDiscountAmount.Text;
Response.Redirect("Confirm.aspx");
Session["Total"] = lblTotalPrice.Text;
Response.Redirect("Confirm.aspx");
}
Confirm.aspx
<form id="form1" runat="server">
<h1>Quotation confirmation</h1>
<label>Sales price</label><asp:Label ID="lblSalesPrice" runat="server" CssClass="result"></asp:Label><%=Session["Sales"] %><br /><br />
<label>Discount amount</label><asp:Label ID="lblDiscountAmount" runat="server" CssClass="result"><%=Session["Amt"] %></asp:Label><br /><br />
<label>Total price</label><asp:Label ID="lblTotalPrice" runat="server" CssClass="result"><%=Session["Price"] %></asp:Label><br />
<h2>Send confirmation to</h2>
<label>Name</label>
<asp:TextBox ID="txtName" runat="server" CssClass="entry"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" CssClass="validator">Required</asp:RequiredFieldValidator><br />
<label>Email address</label>
<asp:TextBox ID="txtEmail" runat="server" CssClass="entry"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtEmail" Display="Dynamic" ErrorMessage="RequiredFieldValidator" CssClass="validator">Required</asp:RequiredFieldValidator><br />
<asp:Button ID="btnSubmit" runat="server" Text="Send Quotation" CssClass="button" OnClick="btnSubmit_Click" />
<asp:Button ID="btnReturn" runat="server" Text="Return" PostBackUrl="~/Default.aspx" CausesValidation="false" CssClass="button" OnClick="btnReturn_Click" />
<p><asp:Label ID="lblMessage" runat="server" ViewStateMode="Enabled" /></p>
</form>
If someone would take the time out and review what I have here. I would appreciate. There is nothing pertinent on the code behind on the Confirm.aspx.cs.
Code behind default.aspx
protected void ConfirmButton_Click(object sender, EventArgs e)
{
Session["Sales"] = txtSalesPrice.Text;
Session["Amt"] = lblDiscountAmount.Text;
Session["Total"] = lblTotalPrice.Text;
Response.Redirect("Confirm.aspx");
}
And you get value in another page like this
In .cs
txtSales.text = Session["Sales"];
In .aspx
<asp:TextBox ID="txtSales" runat="server" Text='<%# Session["Sales"] %>' >
I currently having a problem of when I upload a image using asyncfileupload and button inside a updatepanel1, the entire page refresh instead of the image tag in updatepanel2 reload only. How do I make sure that ONLY the image tag in updatepanel2 reload and not the entire page? Do help me out in this problem. THANKS! My markup code is show below.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript" language="javascript">
function StartUpload(sender, args) {
var filename = args.get_fileName();
var path = args.get_path();
if (filename != "") {
// code to get File Extension..
var arr1 = new Array;
arr1 = filename.split("\\");
var len = arr1.length;
var img1 = arr1[len - 1];
var filext = img1.substring(img1.lastIndexOf(".") + 1);
// Checking Extension
if (filext == "jpg" || filext == "JPG") {
$get("<%=lblUpload.ClientID %>").innerHTML = "";
$get("<%=btnUpload.ClientID %>").disabled = false;
return true;
}
else {
$get("<%=lblUpload.ClientID %>").innerHTML = "Only .jpg and .JPG image allowed.";
$get("<%=btnUpload.ClientID %>").setAttribute('disabled', 'disabled');
return false;
}
}
}
</script>
<asp:ScriptManager ID="ScriptManager1"
runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table width="75%" align="center">
<tr>
<td colspan="5" class="auto-style1">
<h2 align="center">My Profile</h2>
<br />
</td>
</tr>
<tr>
<td id ="memberprofileimage" align="center" class="auto-style2">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Image ID="Image1" runat="server" Height="200" src="image/defaultProfile.jpg" Width="200" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
<br />
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
CompleteBackColor="Lime" UploaderStyle="Modern"
ErrorBackColor="Red" ThrobberID="Throbber"
UploadingBackColor="#66CCFF"
OnClientUploadStarted="StartUpload"
align="center" />
<br />
<br />
<asp:Label ID="Throbber" runat="server" Style="display: none">
<img src="image/indicator.gif" alt="loading" />
</asp:Label>
<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload" />
<br />
<br />
<asp:Label ID="lblUpload" runat="server" Text=""></asp:Label>
</td>
<td id ="memberprofiledetail" align="left" width="50%">
<b> Full Name
<br />
</b>
<asp:TextBox ID="txtFullName" runat="server" ReadOnly="True" Width="270px"></asp:TextBox>
<br />
<b>Contact </b> <br />
<asp:TextBox ID="txtContact" runat="server" ReadOnly="True" Width="160px"></asp:TextBox>
<br />
<b>Address
<br />
</b>
<asp:TextBox ID="txtAddress" runat="server" ReadOnly="true" style="overflow:auto;" TextMode="MultiLine"></asp:TextBox>
<br />
<b>Email
<br />
</b>
<asp:TextBox ID="txtEmail" runat="server" ReadOnly="True" Width="270px"></asp:TextBox>
<br />
<asp:RegularExpressionValidator ID="revContact" runat="server"
ControlToValidate="txtContact"
ValidationExpression="^[0-9]{8}$"
ErrorMessage="Please enter your Contact Number." ForeColor="Red">
</asp:RegularExpressionValidator>
<br />
<asp:RequiredFieldValidator ID="rfvAddress" runat="server"
ErrorMessage="Please enter your Address."
ControlToValidate="txtAddress" ForeColor="Red">
</asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator ID="revEmail" runat="server"
ControlToValidate="txtEmail"
ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"
ErrorMessage="Please enter a valid Email." ForeColor="Red">
</asp:RegularExpressionValidator>
<br />
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
<br />
<asp:Button ID="BtnDisplay" runat="server" Text="Edit profile" CausesValidation="False" OnClick="BtnDisplay_Click" />
<br />
<br />
<asp:Button ID="btnUpdate" runat="server" Text="Update Profile" OnClick="btnUpdate_Click" Visible="False" />
<br />
<br />
<asp:Button ID="btnChangePassword" runat="server" Text="Change Password" OnClick="btnChangePassword_Click" CausesValidation="False" />
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
Asyncpostbacktrigger don't work with files for security reasons .So full postback is needed in your scenario.
File Upload Issue with UpdatePanel
Here is a great Example of what you need.
I'm trying to use onclientclick with onclick. The problem is that the page refreshes before any javascript code is run. I'm trying to integrate my javascript code into someone else's code. I know there's a lot of bad coding practices on his code, but I'm required to work with it. If you want me to isolate the code more, I can do that also. I've tried removing onclick and onclientclick. The page still refreshes.
aspx file
Online Checks
<center>
<h2>
Alvey Quality Monitoring Scheme</h2></center>
<div>
<h3>
Every 1/2 hour, check a unit from each line for the following:
Line 1 Global ID
Line 2 Global ID
Lines Running </h3>
<h3>
<asp:DropDownList ID="DropdownList1" runat="server" Height="20px" Width="85px" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="intSKU" DataValueField="strSpec" AppendDataBoundItems="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="Select" Value="0" />
</asp:DropDownList><asp:TextBox ID="TextBox1" runat="server" Height="20px" Width="63px" ReadOnly="True"></asp:TextBox><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Nestle1ConnectionString2 %>"
SelectCommand="SELECT [intSKU], [strSpec] FROM [lkpSKUInfo] ORDER BY [intSKU]"></asp:SqlDataSource>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropdownList1"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="DropdownList2"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="DropDownList3"></asp:RequiredFieldValidator>
<asp:DropDownList ID="DropdownList2" runat="server"
Height="20px" Width="85px" AutoPostBack="True" DataSourceID="SqlDataSource1" AppendDataBoundItems="true" DataTextField="intSKU" DataValueField="strSpec" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
<asp:ListItem Text="Select" Value="0" />
</asp:DropDownList><asp:TextBox ID="TextBox2" runat="server" Height="20px" Width="63px" ReadOnly="True"></asp:TextBox>
Line 1
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged1" Checked="True" />
Line 2 <asp:CheckBox ID="CheckBox2" runat="server" OnCheckedChanged="CheckBox2_CheckedChanged" AutoPostBack="True" Checked="True" />
</h3>
<h3>
<asp:Label ID="Label1" runat="server" Height="28px" Text="Line 1 Label View " Width="148px"></asp:Label>
<asp:Label ID="Label2" runat="server" Height="28px" Text="Line 2 Label View" Width="148px"></asp:Label></h3>
<p>
<asp:Image ID="Image1" runat="server" Height="155px" Width="670px" />
<asp:Image ID="Image2" runat="server" Height="155px" Width="670px" /></p>
<h3>
<asp:Label ID="Label3" runat="server" Height="28px" Text="Line 1 Print Apply View"
Width="219px"></asp:Label>
<asp:Label ID="Label4" runat="server" Height="28px" Text="Line 2 Print Apply View"
Width="207px"></asp:Label> </h3>
<h3>
<asp:Image ID="Image3" runat="server" Height="155px" Width="670px" />
<asp:Image ID="Image4" runat="server" Height="155px" Width="670px" />
</h3>
<h3>
<asp:Label ID="Label6" runat="server" Height="17px" Text="CASE CODE: " Width="133px"></asp:Label>
<asp:Label ID="Label9" runat="server" Height="17px" Text="Line 1"
Width="108px"></asp:Label>
<asp:Label ID="Label10" runat="server" Height="17px" Text="Line 2"
Width="108px"></asp:Label></h3>
<h3>
<asp:Label ID="Label5" runat="server" Height="39px" Text="Case code must match the line and hour from the can code"
Width="904px"></asp:Label>
<asp:CheckBox ID="CheckBox3" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox3_CheckedChanged" Checked="True" />
<asp:CheckBox ID="CheckBox4" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox4_CheckedChanged" Checked="True" /></h3>
<h3>
<asp:Label ID="Label7" runat="server" Height="17px" Text="SHRINK FILM" Width="122px"></asp:Label> </h3>
<h3>
<asp:Label ID="Label8" runat="server" Height="39px" Text="Shrink Film must be intact, tightly covering the entire case, and have bullseyes that are tight and will not allow a can to fall out" Width="904px"></asp:Label>
<asp:CheckBox ID="CheckBox5" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox5_CheckedChanged" Checked="True" />
<asp:CheckBox ID="CheckBox6" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox6_CheckedChanged" Checked="True" /></h3>
<h3>
<asp:Label ID="Label11" runat="server" Height="17px" Text="LABELS"
Width="122px"></asp:Label> </h3>
<h3>
<asp:Label ID="Label12" runat="server" Height="39px" Text="Labels must be correct for SKU scheduled to be produced, be applied correctly to the cans with no loose, crooked or upside-down labels" Width="904px"></asp:Label>
<asp:CheckBox ID="CheckBox7" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox7_CheckedChanged" Checked="True" />
<asp:CheckBox ID="CheckBox8" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox8_CheckedChanged" Checked="True" /></h3>
<h3>
<asp:Label ID="Label13" runat="server" Height="17px" Text="TRAYS"
Width="122px"></asp:Label></h3>
<h3>
<asp:Label ID="Label14" runat="server" Height="39px" Text="Trays must match product produced, no double case, no loose flaps and no damaged cases" Width="904px"></asp:Label>
<asp:CheckBox ID="CheckBox9" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox9_CheckedChanged" Checked="True" />
<asp:CheckBox ID="CheckBox10" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox10_CheckedChanged" Checked="True" /></h3>
<h3>
<asp:Label ID="Label15" runat="server" Height="17px" Text="PRINT & APPLY"
Width="166px"></asp:Label></h3>
<h3>
<asp:Label ID="Label16" runat="server" Height="39px" Text="Print & Apply stickers must match SKU produced, Julian Date, Best Before Date, Line and Time. Must be legible and applied correctly to the case. Stickers must match DIS ticket (except Australia)" Width="904px"></asp:Label>
<asp:CheckBox ID="CheckBox11" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox11_CheckedChanged" Checked="True" />
<asp:CheckBox ID="CheckBox12" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox12_CheckedChanged" Checked="True" /></h3>
<h3>
<asp:Label ID="Label17" runat="server" Height="17px" Text="DIS TAG"
Width="166px"></asp:Label></h3>
<h3>
<asp:Label ID="Label18" runat="server" Height="39px" Text="Tags must match schedule and product produced" Width="904px"></asp:Label>
<asp:CheckBox ID="CheckBox13" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox13_CheckedChanged" Checked="True" />
<asp:CheckBox ID="CheckBox14" runat="server" Text="OK/Defective" OnCheckedChanged="CheckBox14_CheckedChanged" Checked="True" /></h3><br />
<h3>
Comments:
Operator Number
<asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="true" Height="20px" Width="72px" DataSourceID="SqlDataSource2" DataTextField="intOperatorNumber" DataValueField="strLast">
<asp:ListItem Text="Select" Value="No Operator Selected" />
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Nestle1ConnectionString2 %>"
SelectCommand="SELECT [intOperatorNumber], [strLast] FROM [tblOperators] ORDER BY [intOperatorNumber]">
</asp:SqlDataSource>
Shift <asp:Label ID="Label" runat="server" Height="20px" Width="53px"></asp:Label>
</h3>
</div>
<asp:TextBox ID="TextBox3" runat="server" Height="81px" Width="381px"></asp:TextBox>
<asp:Label ID="lbl" runat="server" Height="20px" Width="80" BorderWidth="0px" Font-Names="Verdana"></asp:Label>
<input type="text" id="clock" style="border: 0px; width: 80px; height: 20px;" value="" readonly="readonly" />
Specific part of code not working
<!-- the button I'm clicking-->
<asp:Button ID="Button3" Font-Size="15" runat="server" Text="Send Data" Height="40px" Width="245px" OnClientClick="delayer();return false;" OnClick="Button3_Click" />
<asp:Button ID="Button4" Font-Size="15" runat="server" Text="Back" Height="40px" Width="245px" OnClick="Button4_Click" />
</form>
<script type="text/javascript">
</script>
<script type="text/javascript">
/*
var executionTime;
var initialTime = localStorage.getItem("initialTime");
function foo()
{
if(!(initialTime === null)){
executiontime = 5000-(new Date()).getTime() - parseInt(initialTime, 10);
if (executionTime<0) executionTime = 0;
showPopUp(executionTime);
}
}
*/
function showPopUp( var executionTime){
/* if(initialTime=== null)
{
executionTime = 5000;
}
localStorage.setItem("initialTime", (new Date()).getTime());
setTimeout(function() {alert("Warning");
localStorage.setItem("initialTime", null);}, executionTime);
*/
alert("warning");
}
function delayer(){
showPopUp();
}
// constants to define the title of the alert and button text.
var ALERT_TITLE = "Oops!";
var ALERT_BUTTON_TEXT = "Ok";
// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts
if(document.getElementById) {
window.alert = function(txt) {
createCustomAlert(txt); //overrides alert method
}
}
function createCustomAlert(txt) {
// shortcut reference to the document object
d = document;
// if the modalContainer object already exists in the DOM, bail out.
if(d.getElementById("modalContainer")) return;
// create the modalContainer div as a child of the BODY element
mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
mObj.id = "modalContainer";
// make sure its as tall as it needs to be to overlay all the content on the page
mObj.style.height = document.documentElement.scrollHeight + "px";
// create the DIV that will be the alert
alertObj = mObj.appendChild(d.createElement("div"));
alertObj.id = "alertBox";
// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
if(false) alertObj.style.top = document.documentElement.scrollTop + "px";
// center the alert box
alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
// create an H1 element as the title bar
h1 = alertObj.appendChild(d.createElement("h1"));
h1.appendChild(d.createTextNode(ALERT_TITLE));
// create a paragraph element to contain the txt argument
msg = alertObj.appendChild(d.createElement("p"));
msg.innerHTML = txt;
// create an anchor element to use as the confirmation button.
btn = alertObj.appendChild(d.createElement("a"));
btn.id = "closeBtn";
btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
btn.href = "#";
// set up the onclick event to remove the alert when the anchor is clicked
btn.onclick = function() { removeCustomAlert();return false; }
}
// removes the custom alert from the DOM
function removeCustomAlert() {
document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
</script>
</body>
</html>
You need to return false from delayer function, and also add return to OnClientClick event.
<asp:Button ID="Button3" runat="server" Text="Send Data"
OnClientClick="return delayer();" OnClick="Button3_Click" />
function delayer(){
showPopUp();
return false;
}
I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
I've set the ViewStateMode to "Disabled". I'm just hoping it won't back fire somewhere else.
Your existing code might work if you drop an update panel and place your controls inside it.
Alternatively you can create a property in your page like
private bool myRowCount;
protected bool HasRowsMyData
{
get { return myRowCount; }
set { myRowCount=value; }
}
Then inside your selectedIndex change event
if (dt.Rows.Count == 1)
{
HasRowsMyData=true;
//DataBind your controls here
YourUpdatePanel.Update();
}
Inside your aspx on panels you can set each panel's visible property like this so whenever page is updated they will turn on/off depeding upon the result
Visible='<%#HasRowsMyData%>'
Visible='<%#!HasRowsMyData%>'
If you like to do it client side I advise jQuery's toggle function
jQuey:toggle()