Website starts working after a few seconds - c#

I am quite new in websites and web applications. I have created a website which works correctly on localhost IIS but when I put it on server it is not working properly. I have to wait for a while until it starts working. I also get the following error when I select items in dropdown: (it's on the bottom-left corner of the window)
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E; InfoPath.3; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; MS-RTC LM 8)
Timestamp: Tue, 26 Mar 2013 13:07:37 UTC
Message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
Line: 869
Char: 13
Code: 0
I set the trace to true and it works now. But it doesn't seem to be a good solution as I still see that error when I select items in dropbox. Do you have any good suggestion for this? should I add or remove something from configuration file or somewhere else? Following is my web.cinfig
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation targetFramework="4.0" debug="true"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"
viewStateEncryptionMode="Always"/>
<trace
enabled="true"/>
</system.web>
</configuration>

Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it,
If you've used the Microsoft ASP.NET AJAX UpdatePanel control, there's a good chance you've hit the "Sys.WebForms.PageRequestManagerParserErrorException" error.

I actually no sure what is throwing this error. in my webform im using updatepanel. rhis is part of my web form.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>DTC</title>
</head>
<body bgcolor="#333333">
<h1 align="center" style="font-family: Arial; color: #FFFF99; height: 40px; font-
weight: bold;
font-size: 50px; min-width: 900px;" title="Header">
DTC Viewer</h1>
<form id="form1" runat="server" style="margin: 50px 100px 50px 100px; min-width: 700px;
background-color: #C0C0C0; font-family: Arial, Helvetica, sans-serif;">
<div align="center" style="width: 100%">
<asp:UpdatePanel ID="CheckboxUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table id="MainTable" runat="server" style="margin-left: 100px;">
<tr>
<td>
<asp:UpdatePanel ID="BrandUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td style="padding-bottom: 5px;">
<asp:Label ID="BrandLabel" runat="server" Text="Brand :" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" CssClass="MyLabel" Width="8em"
style="margin-right: 1em;text-align: right;"></asp:Label>
</td>
<td style="padding-bottom: 5px;">
<asp:TextBox ID="Brand" runat="server" Height="15px" Width="176px" Text="VTC" BackColor="#FFFFCC"
CssClass="MyDropBox" AutoPostBack="True" ForeColor="#666666" ReadOnly="True"></asp:TextBox>
<asp:Label ID="StarLabel1" runat="server" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" Width="1em"
style="text-align: left;" Text="*"></asp:Label>
</td>
<td style="padding-bottom: 5px;">
<asp:RequiredFieldValidator ID="BrandValidator" runat="server" ErrorMessage="Basic Search: Brand is required"
ControlToValidate="Brand" InitialValue="" ForeColor="Red" Width="15em" CssClass="ErrorMessage"
Font-Size="Small"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="ModelLabel" runat="server" Text="Model :" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" CssClass="MyLabel" Width="8em"
style="margin-right: 1em;text-align: right;"></asp:Label>
</td>
<td>
<asp:TextBox ID="Model" runat="server" Height="15px" Width="176px" Text="FH(4)" BackColor="#FFFFCC"
CssClass="MyDropBox" AutoPostBack="True" ForeColor="#666666" ReadOnly="True"></asp:TextBox>
<asp:Label ID="StarLabel2" runat="server" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" Width="1em"
style="text-align: left;" Text="*"></asp:Label>
</td>
<td>
<asp:RequiredFieldValidator ID="ModelValidator" runat="server" ErrorMessage="Basic Search: Model is required"
ControlToValidate="Model" InitialValue="" ForeColor="Red" Width="15em" CssClass="ErrorMessage"
Font-Size="Small"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label ID="KTXLabel" runat="server" Text=" Emission level :"
Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" CssClass="MyLabel" Width="8em"
style="margin-right: 1em;text-align: right; margin-left: 0px;"></asp:Label>
</td>
<td>
<asp:DropDownList ID="KTX" runat="server" BackColor="#FFFFCC" ForeColor="#666666"
Height="21px" Style="margin-left: 0px" Width="182px" OnSelectedIndexChanged="KTX_SelectedIndexChanged"
CssClass="MyDropBox" DataTextField="text" DataValueField="value" AutoPostBack="True">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Font-Names="Arial" Font-Size="Medium"
ForeColor="#333333" Width="1em"
style="text-align: left;" Text="*"></asp:Label>
</td>
<td>
.........
..........
</ContentTemplate>
</asp:UpdatePanel>
<div style="width: 123px; margin-left: 7px; z-index: inherit;">
<asp:Button ID="getURLButton" runat="server" Height="32px" OnClick="getURLButton_Click"
Text="Submit" Width="134px" BackColor="#DD5800" BorderColor="Gray" Font-Bold="True"
Class="MyButton" Font-Size="Large" ForeColor="#4E4E4E" />
</div>
<br />
</div>
</form>

Related

Button Refresh Not clearing text

I'm making a captcha for my site, nothing fancy and for personal use. My problem is that when i hit the refresh button to bring up a new image in the captcha box it should reset the captcha text box as well.
I am setting it like so
protected void btnRefresh_Click(object sender, EventArgs e)
{
//This is the call that creates a new image
FillCaptcha();
// to clear the text box
txtCaptcha.Text = String.Empty;
}
When i run the debugger it shows the values entered in the text box and after when its set to "".
Here is the button and text box layout
<asp:TableRow>
<asp:TableCell>
Enter Below Captcha Code :
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="txtCaptcha" runat="server" Width="200px"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
</asp:TableCell>
<asp:TableCell VerticalAlign="middle">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UP1" runat="server">
<ContentTemplate>
<table>
<tr>
<td style="height: 50px; width:120px; border:solid; border-color:blue; text-align:center;">
<asp:Image ID="imgCaptcha" runat="server" />
</td>
<td valign="middle">
<asp:Button ID="btnRefresh" runat="server" Text="Refresh" OnClick="btnRefresh_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:TableCell>
</asp:TableRow> `
Ive search on Stack for some time and everyone seems to be setting it as i have it. I have the same call to the txtCaptcha.Text = String.Empty; in another function and it works fine. any help would be grateful. If I'm unclear about something let me know and ill do my best to better explain it.
Captcha layout
You should move your TextBox inside UpdatePanel. Like So:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UP1" runat="server">
<ContentTemplate>
<table>
<tr>
<td colspan="2">
<asp:TextBox ID="txtCaptcha" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="height: 50px; width:120px; border:solid; border-color:blue; text-align:center;">
<asp:Image ID="imgCaptcha" runat="server" />
</td>
<td valign="middle">
<asp:Button ID="btnRefresh" runat="server" Text="Refresh" OnClick="btnRefresh_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
Read about Introduction to the UpdatePanel Control

Unable to check RadioButton inside DataList footer Template

I have kept two radio button inside a datalist footer template but I am not at all able to select it. Below is my footer template:
<FooterTemplate>
<tr>
<td align="right" colspan="7"><br />
</td>
</tr>
<tr>
<td align="left" valign="middle" colspan="7">
<div style="background-color:#FCEE21; height:47px ;">
<div style=" position:relative; top:15px; left:20px;">
<asp:CheckBox ID="cbAgree" Checked="true" Text="I agree on all terms & conditions" runat="server" />
</div>
<div style=" position:relative; top:-1px; left:410px;">
<asp:Label ID="Label2" runat="server" Text="Total: (INR)"></asp:Label>
</div>
<div style=" position:relative; top:-22px; left:550px;">
<asp:Label ID="lbltotal" runat="server" Text="000000" Font-Size="14pt"></asp:Label>
</div>
</div>
</td>
</tr>
<tr>
<td align="right" colspan="7">
<div style="background-image: url(images/footerBg.png); height:47px ;">
<div style=" position:relative; top:10px; left:-172px;">
<asp:Label ID="Label9" runat="server" Text="Select an option: "></asp:Label>
<asp:RadioButton ID="rb1" Text="Colect" AutoPostBack="true" runat="server" GroupName="rboption"/>
<asp:RadioButton ID="rb2" Text="Deliver" AutoPostBack="true" runat="server" GroupName="rboption"/>
</div>
<div style=" position:relative; top:-18px;">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" BackColor="#F8CD20" CssClass="anchor"
BorderColor="#F8CD20" BorderStyle="None" OnClick=" Submit_Clicked" Font-Bold="True" Font-Size="14pt"
Height="38px" Width="105px" />
</div>
</div>
</td>
</tr>
</FooterTemplate>
I have not done any databinding also. Please help me out, if I missed out something.
Your problem is about your css styling. If you remove inline css styles from your divs you can click them.
Those divs are displaying on top of each other without proper styles and radiobuttons stay under another div, prevents you clicking on them.
Or if you want to keep the styles and still click them you can use "z-index" attribute with adding z-index:1;, so you bring the div with radiobuttons, above the other div, making them clickable.
....
<div style=" position:relative; top:10px; left:-172px; z-index:1;">
<asp:Label ID="Label9" runat="server" Text="Select an option: "></asp:Label>
<asp:RadioButton ID="rb1" Text="Colect" AutoPostBack="true" runat="server" GroupName="rboption"/>
<asp:RadioButton ID="rb2" Text="Deliver" AutoPostBack="true" runat="server" GroupName="rboption"/>
</div>
....

ASP.NET ListView Padding

I am using two listviews to display two tag clouds (a red one and a green one). When the tag gets quite big, it overlaps the smaller ones. Is there a way to space out the tags, i.e vertical padding or something?
<div style="padding-left: 25px; padding-right: 25px; text-align: center;">
<asp:listview runat="server" ID="ListView1" ItemPlaceholderID="itemPlaceHolder">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<%# Eval("Tag") %>
</ItemTemplate>
<EmptyDataTemplate>
<asp:Label ID="negative_tags" runat="server" Text=""></asp:Label>
</EmptyDataTemplate>
</asp:listview>
</div>
<br />
<div style="padding-left: 25px; padding-right: 25px; text-align: center;">
<asp:listview runat="server" ID="ListView2" ItemPlaceholderID="itemPlaceHolder">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<%# Eval("Tag") %>
</ItemTemplate>
<EmptyDataTemplate>
<asp:Label ID="positive_tags" runat="server" Text=""></asp:Label>
</EmptyDataTemplate>
</asp:listview>
</div>
Yes,
on your <a> tags you can add:
line-height: 30px
or alternativelly you can add
padding-top:5px; padding-bottom:5px

Password Recovery tool in C# not working

Hi (I'm pretty new to this),
I have created a portal where the user logs in and within that, they can view other programs I've made. The problem is the password recovery does not seem to be working - I get no error messages, I just get the message "We were unable to access your information. Please try again."
I have the ASP.NET configuration setup correctly and have tested this with different users and permissions but I was just wondering if there is something I need to do in the configuartion manager or the web.config so that this can work.
Below is the code for the password recovery tool:
<form id="form1" runat="server">
<div align="center">
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server" Height="147px" Width="442px" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em">
<UserNameTemplate>
<table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse">
<tr>
<td style="width: 445px">
<table border="0" cellpadding="0" style="width: 442px; height: 147px">
<tr>
<td align="center" colspan="2">
<strong><span style="font-size: 0.9em">Password Recovery</span></strong></td>
</tr>
<tr>
<td align="center" colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label></td>
<td style="width: 291px">
<asp:TextBox ID="UserName" runat="server" Width="187px"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="PasswordRecovery1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: red">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2" style="text-align: right">
<asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="Submit" ValidationGroup="PasswordRecovery1"
Width="103px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</UserNameTemplate>
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<SuccessTextStyle Font-Bold="True" ForeColor="#5D7B9D" />
<TextBoxStyle Font-Size="0.8em" />
<TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
<SubmitButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
</asp:PasswordRecovery>
</div>
</form>
Thank you.
If you get this error ("We were unable to access your information. Please try again") for one user (but other users work fine), most likely it's just the account is locked.
To unlock the account run the stored procedure: [aspnetdb].[dbo].[aspnet_Membership_UnlockUser]
You need to pass in your application name, and the username to unlock.
If you don't know your application name, you can check from the [aspnetdb].[dbo].[aspnet_Applications] table.
Looks right to me.
Check your webconfig to make sure your membership provider has
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
Also you need to set up a mail definition in your web.config for the control to be able to mail the new password.
<mailSettings>
<smtp from="from#from.com">
<network host="your.smtp.server" port="25"/>
</smtp>
</mailSettings>

UpdateProgress and FileUpload problem

I have a fileupload control with an updatePprogress in an updatePanel like this:
UpdatePanel is: updExtraSmall
<Triggers>
<asp:PostBackTrigger ControlID="lnkExtraSmall" />
</Triggers>
<ContentTemplate>
<table>
<tr>
<td style="border: 1px">
<asp:FileUpload ID="fupldExtraSmall" runat="server" />
</td>
<td>
<asp:LinkButton ID="lnkExtraSmall" OnClientClick="javascript:showWait();" OnClick="lnkExtraSmall_click" CausesValidation="false"
runat="server" Text="Upload" />
<asp:Label ID="lblMessage" runat="server" />
</td>
<td>
<asp:Label ID="lblExtraSmallMessage" runat="server" />
</td>
<td>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updExtraSmall">
<ProgressTemplate>
<DIV id="IMGDIV" align="center" valign="middle" runat="server" style="position: absolute;left: 35%;top: 25%;visibility:visible;vertical-align:middle;border-style:inset;border-color:black;background-color:White">
<img src="loading/loading.gif" /><br />
</DIV>
</ProgressTemplate>
</asp:UpdateProgress>
</td>
</tr>
</table>
</ContentTemplate>
and:
function showWait()
{
if ($get('fupldExtraSmall').value.length > 0)
{
$get('UpdateProgress1').style.display = 'block';
}
}
The problem is that the updateProgrss doesn't show.
Can anyone help me please?
Thank you,
Alina
Just Use the asyncfileupload control which come with ajaxcontroltoolkit 3.0 and then upload the file.
Put the UpdateProgress outside the ContentTemplate.
Ref: http://msdn.microsoft.com/en-us/library/bb398821.aspx

Categories

Resources