473,322 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

.net Ajax asyncronus postback probs

HI
all

I have created a user ctrl for user info.
On which i have used some asp ctrls, .net Ajax (Atlas) Ctrls and
validation as described below

Name TxtBox1(RequiedFieldValidator, RagexValidetor)
Email TxtBox2(RequiedFieldValidator, RagexValidetor)
Mobile Txtbox3(RagexValidetor)
Date of Birth txtBox4+CalenderExtender(Ajax Ctrl tool kit)(RagexValidetor)
Country DropDownMenu1 (autoppostback)
State DropDownMenu2 (autoppostback)
City DropDownMenu3 (autoppostback)
Address TextBox5
Pincode TextBox6

When i select country the state list is populated and slecting sate the
city list is populated and city selection prefills the pincode.
The whole User Ctrl is places in User.aspx in a UpdatePanel. so all the
post backs are asyncronus callbacks.
Problem is that when i selects the country all the Validation goes
inactive using firefox. an in ie it given null exception alert please help
me
Thx in advance

:
MUKESH AGARWAL
DELHI

Mar 15 '07 #1
3 1734
Hi Mukesh,

Would you please post a complete code listing of your control so that I can
reproduce the issue on my side? Thanks.

By the way, please note CalendarExtender is part of AJAX Control Toolkit
that is shared source supported by community.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 15 '07 #2
Hi Mukesh,

Is the issue solved now?

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 18 '07 #3
// The .ascx file
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="EditProfile.ascx.cs" Inherits="UserControls_EditProfile" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
First Name
</td>
<td>
<asp:TextBox ID="tbFirstName" runat="server" ReadOnly="True"
></asp:TextBox></td>
</tr>
<tr>
<td>
Middle Name
</td>
<td>
<asp:TextBox ID="tbMiddleName" runat="server" MaxLength="50"
></asp:TextBox></td>
</tr>
<tr>
<td>
Last Name
</td>
<td>
<asp:TextBox ID="tbLastName" runat="server" ReadOnly="True"
></asp:TextBox></td>
</tr>
<tr>
<td>
Email</td>
<td>
<asp:TextBox ID="tbEmail" runat="server" ReadOnly="True"
></asp:TextBox></td>
</tr>
<tr>
<td>
Date Of Birth</td>
<td>
<asp:TextBox ID="tbDate" runat="server" AutoCompleteType="Disabled"
></asp:TextBox>
<div style="font-size: 90%">
<em>(Set the focus to the textbox to show the calendar)</em></div>
<ajaxToolkit:CalendarExtender
ID="CalendarExtender1" runat="server" Format="MMMM d, yyyy"
TargetControlID="tbDate" FirstDayOfWeek="Sunday">
</ajaxToolkit:CalendarExtender>
</td>
</tr>
<tr>
<td>
Gender
</td>
<td>
<asp:RadioButtonList ID="rblGen" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem Selected="True" Value="1">Male</asp:ListItem>
<asp:ListItem Value="0">Female</asp:ListItem>
</asp:RadioButtonList></td>
</tr>
<tr>
<td>
Telephone
</td>
<td>
<asp:TextBox ID="tbTelIsd" runat="server" MaxLength="4"
></asp:TextBox><asp:RegularExpressionValidator
ID="revTelIsd" runat="server" ControlToValidate="tbTelIsd"
ErrorMessage="Enter the Proper ISD Code"
SetFocusOnError="True" ValidationExpression="([0-9]+)$"
>*</asp:RegularExpressionValidator>
<asp:TextBox ID="tbTelStd" runat="server" MaxLength="7"
></asp:TextBox><asp:RegularExpressionValidator
ID="revTelStd" runat="server" ControlToValidate="tbTelStd"
ErrorMessage="Enter the Proper STD Code,max Length is 4"
SetFocusOnError="True" ValidationExpression="([0-9]+)$"
>*</asp:RegularExpressionValidator><asp:TextBox ID="tbTelLcl" runat="server"
MaxLength="20" ></asp:TextBox><asp:RegularExpressionValidator
ID="revTelLcl" runat="server" ControlToValidate="tbTelLcl"
ErrorMessage="Only integers value allowed"
SetFocusOnError="True" ValidationExpression="([0-9]+)$"
>*</asp:RegularExpressionValidator></td>
</tr>
<tr style="color: #000000">
<td>
Mobile
</td>
<td>
<asp:TextBox ID="tbMobIsd" runat="server" MaxLength="4"
></asp:TextBox><asp:RegularExpressionValidator
ID="revMobIsd" runat="server" ControlToValidate="tbMobIsd"
ErrorMessage="Enter the Proper ISD Code"
SetFocusOnError="True" ValidationExpression="([0-9]+)$"
>*</asp:RegularExpressionValidator>
<asp:TextBox ID="tbMobLcl" runat="server" MaxLength="20"
></asp:TextBox><asp:RegularExpressionValidator
ID="revMobLcl" runat="server" ControlToValidate="tbMobLcl"
ErrorMessage="Only integers value allowed"
SetFocusOnError="True" ValidationExpression="([0-9]+)$"
>*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td colspan="2">
Address
</td>
</tr>
<tr>
<td>
Country</td>
<td>

<ContentTemplate>
<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True"
DataSourceID="XmlDataSource1"
DataTextField="name" DataValueField="countryCode"
OnDataBound="ddlCountry_DataBound"
OnSelectedIndexChanged="ddlCountry_SelectedIndexCh anged">
<asp:ListItem Selected="True" Value="0">--- Select Country
---</asp:ListItem>
</asp:DropDownList><asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/CountriesStates.xml"
XPath="root/Countries/country"></asp:XmlDataSource>
</ContentTemplate>

</td>
</tr>
<tr>
<td>
State</td>
<td>

<ContentTemplate>
<asp:DropDownList ID="ddlStt" runat="server" AutoPostBack="True"
DataSourceID="XmlDataSource2"
DataTextField="Name" DataValueField="id"
OnSelectedIndexChanged="ddlStt_SelectedIndexChange d"
OnDataBound="ddlStt_DataBound">
<asp:ListItem Selected="True" Value="0">--- Select State
---</asp:ListItem>
</asp:DropDownList><asp:TextBox ID="tbState" runat="server" MaxLength="50"
Visible="False"></asp:TextBox><asp:XmlDataSource
ID="XmlDataSource2" runat="server"
DataFile="~/App_Data/CountriesStates.xml"
XPath="root/states/state"></asp:XmlDataSource>
</ContentTemplate>

<asp:RegularExpressionValidator
ID="revSta" runat="server" ControlToValidate="tbState"
ErrorMessage="RegularExpressionValidator"
SetFocusOnError="True"
ValidationExpression="^(\w*\W*\w*\W*)*[^0-9][^<>]"
>*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>
City</td>
<td>

<ContentTemplate>
<asp:DropDownList ID="ddlCti" runat="server"
OnSelectedIndexChanged="ddlCti_SelectedIndexChange d" AutoPostBack="True">
</asp:DropDownList>
<asp:TextBox ID="tbCity" runat="server" MaxLength="50"
Visible="False">My City</asp:TextBox>
</ContentTemplate>

<asp:RegularExpressionValidator
ID="revCty" runat="server" ControlToValidate="tbCity"
ErrorMessage="RegularExpressionValidator"
SetFocusOnError="True"
ValidationExpression="^(\w*\W*\w*\W*)*[^0-9][^<>]"
>*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>
Locality</td>
<td>

<ContentTemplate>
<asp:DropDownList ID="ddlLocal" runat="server"
OnSelectedIndexChanged="ddlLocal_SelectedIndexChan ged" AutoPostBack="True">
</asp:DropDownList>
<asp:TextBox ID="tbLcl" runat="server" MaxLength="50" Visible="False">My
Locality Name</asp:TextBox>
</ContentTemplate>

<asp:RegularExpressionValidator
ID="revLcl" runat="server" ControlToValidate="tbLcl"
ErrorMessage="RegularExpressionValidator"
SetFocusOnError="True" ValidationExpression='^(\w*\W*\w*\W*)*[^<>"]'
>*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>
Street1</td>
<td>
<asp:TextBox ID="tbStr1" runat="server" MaxLength="100"
></asp:TextBox></td>
</tr>
<tr>
<td>
Street2</td>
<td>
<asp:TextBox ID="tbStr2" runat="server" MaxLength="100"
></asp:TextBox></td>
</tr>
<tr>
<td style="height: 26px">
Pincode</td>
<td>

<ContentTemplate>
<asp:TextBox ID="tbPin1" runat="server" MaxLength="15"
Visible="False"></asp:TextBox><asp:TextBox ID="tbPin" runat="server"
MaxLength="6" ></asp:TextBox>
</ContentTemplate>

<asp:RegularExpressionValidator
ID="revPin" runat="server" ControlToValidate="tbPin" ErrorMessage="Only
6 digit is allowed"
SetFocusOnError="True" ValidationExpression="\d{6}"
>*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:ValidationSummary ID="vsUsrPerIn" runat="server" >
</asp:ValidationSummary>
<asp:Label ID="lblMessage" runat="server"
EnableViewState="False"></asp:Label></td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click"
Text="Submit" /></td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>


//----------------- the ascx.cs file-------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class UserControls_EditProfile : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
/// chk for sseion
/// call prefill
Propertywala.User user =
(Propertywala.User)Session[Propertywala.Constants.CommonConsts.USER_SESSION_N AME];
bool chkNull = Convert.IsDBNull(user.HomeAddress.Country);
if (!Convert.IsDBNull(user.HomeAddress.Country))
{
tbFirstName.Text = user.FirstName;
tbMiddleName.Text = user.MiddleName;
tbLastName.Text = user.LastName;
tbEmail.Text = user.PrimaryEmail;
DateTime dob = new DateTime();
DateTime.TryParse(user.DateOfBirth, out dob);
string dobst = dob.ToLongDateString();
tbDate.Text = dobst.Remove(0, dobst.IndexOf(",") + 1);
rblGen.SelectedIndex = 1;
if (user.IsUserMale)
{
rblGen.SelectedIndex = -1;
rblGen.SelectedIndex = 0;
}

tbTelIsd.Text = user.TelephoneIsd;
tbTelLcl.Text = user.TelephoneLocal;
tbTelStd.Text = user.TelephoneStd;
tbMobIsd.Text = user.MobileIsd;
tbMobLcl.Text = user.MobileLocal;
tbStr1.Text = user.AddressStreet1;
tbStr2.Text = user.AddressStreet2;
if (user.HomeAddress.Pin != "")
{
tbPin.Text = user.HomeAddress.Pin;
tbPin1.Text = user.HomeAddress.Pin;
}
tbCity.Text = user.HomeAddress.City;
tbLcl.Text = user.HomeAddress.Locality;
tbState.Text = user.HomeAddress.State;
}
}
}

protected void btnSubmit_Click(object sender, EventArgs e)
{
Page.Validate("EditProfile");
if (Page.IsValid)
{
Propertywala.User user =
(Propertywala.User)Session[Propertywala.Constants.CommonConsts.USER_SESSION_N AME];
user.MiddleName = tbMiddleName.Text;
user.DateOfBirth = tbDate.Text;
user.IsUserMale = false;
if (rblGen.SelectedValue == "1")
{
user.IsUserMale = true;
}
user.TelephoneIsd = tbTelIsd.Text;
user.TelephoneLocal = tbTelLcl.Text;
user.TelephoneStd = tbTelStd.Text;
user.MobileIsd = tbMobIsd.Text;
user.MobileLocal = tbMobLcl.Text;

user.AddressStreet1 = tbStr1.Text;
user.AddressStreet2 = tbStr2.Text;
user.HomeAddress = new Propertywala.Address();
user.HomeAddress.Country = ddlCountry.SelectedValue;
if (string.Compare(user.HomeAddress.Country, "In", true) == 0)
{
user.HomeAddress.StateId = long.Parse(ddlStt.SelectedValue);
if (ddlCti.SelectedValue.Length 0)
{
user.HomeAddress.CityId = long.Parse(ddlCti.SelectedValue);
}
if (ddlLocal.SelectedValue.Length 0)
{
user.HomeAddress.LocalityId = long.Parse(ddlLocal.SelectedValue);
}
user.HomeAddress.City = tbCity.Text;
user.HomeAddress.Locality = tbLcl.Text;
user.HomeAddress.Pin = tbPin.Text;

}
else
{
user.HomeAddress.State = tbState.Text;
user.HomeAddress.City = tbCity.Text;
user.HomeAddress.Locality = tbLcl.Text;
user.HomeAddress.Pin = tbPin1.Text;
}

user.updateUserData();
lblMessage.Text = Propertywala.Common.CreateWarning("Profile Updated");
Response.Redirect("../User/Profile.aspx?view=ext");
}
}
protected void ddlCountry_DataBound(object sender, EventArgs e)
{
Propertywala.User user =
(Propertywala.User)Session[Propertywala.Constants.CommonConsts.USER_SESSION_N AME];
bool chkNull = Convert.IsDBNull(user.HomeAddress.Country);
if (!chkNull)
{
ddlCountry.Items.FindByValue(user.HomeAddress.Coun try).Selected = true;
}
VisibleInputFields();
}

protected void ddlStt_DataBound(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bool isIndian = false;
if (ddlCountry.SelectedItem.Text == "India")
{
isIndian = true;
}
Propertywala.User user =
(Propertywala.User)Session[Propertywala.Constants.CommonConsts.USER_SESSION_N AME];
bool chkNull = Convert.IsDBNull(user.HomeAddress.State);
if (!chkNull && isIndian)
{
ddlStt.SelectedIndex = -1;
ListItem state = ddlStt.Items.FindByText(user.HomeAddress.State);
if (state != null)
{
state.Selected = true;
}
else
{
tbState.Text = user.HomeAddress.State;
tbState.Visible = true;
}
}
ListItemCollection licLocal =
Propertywala.Address.GetLocalCollection(long.Parse (ddlStt.SelectedValue),
true, "City");
foreach (ListItem li in licLocal)
{
ddlCti.Items.Add(li);
}
chkNull = Convert.IsDBNull(user.HomeAddress.City);
if (!chkNull && isIndian)
{
ddlCti.SelectedIndex = -1;
ListItem city = ddlCti.Items.FindByText(user.HomeAddress.City);
if (city != null)
{
city.Selected = true;
ddlCti.DataBind();
licLocal =
Propertywala.Address.GetLocalCollection(long.Parse (ddlCti.SelectedValue),
true, "Locality");
foreach (ListItem li in licLocal)
{
ddlLocal.Items.Add(li);
}
chkNull = Convert.IsDBNull(user.HomeAddress.Locality);
if (!chkNull && isIndian)
{
ddlLocal.Visible = true;
ddlLocal.SelectedIndex = -1;
ListItem local =
ddlLocal.Items.FindByValue(user.HomeAddress.Locali tyId.ToString());
if (local != null)
{
local.Selected = true;
ddlLocal.DataBind();
}
else
{
tbLcl.Text = user.HomeAddress.Locality;
tbLcl.Visible = true;
ddlLocal.SelectedIndex=ddlLocal.Items.Count-1;

}
}
}
else
{
tbCity.Text = user.HomeAddress.City;
tbCity.Visible = true;
tbLcl.Text = user.HomeAddress.Locality;
tbLcl.Visible = true;
ddlLocal.Visible = false;
ddlCti.SelectedIndex = ddlCti.Items.Count - 1;
}

}

}

}
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{

VisibleInputFields();
}

protected void ddlStt_SelectedIndexChanged(object sender, EventArgs e)
{
ddlCti.Visible = true;
tbCity.Visible = false;
ddlCti.Items.Clear();

ListItemCollection licLocal =
Propertywala.Address.GetLocalCollection(long.Parse (ddlStt.SelectedValue),
true, "City");
foreach (ListItem li in licLocal)
{
ddlCti.Items.Add(li);
}
}
protected void ddlCti_SelectedIndexChanged(object sender, EventArgs e)
{
ddlLocal.Items.Clear();
if (ddlCti.SelectedValue.Length 0 && ddlCti.SelectedValue != "0")
{
ListItemCollection licLocal =
Propertywala.Address.GetLocalCollection(long.Parse (ddlCti.SelectedValue),
true, "Locality");
foreach (ListItem li in licLocal)
{
ddlLocal.Items.Add(li);
}
ddlLocal.Visible = true;
tbLcl.Visible = false;
tbCity.Visible = false;
}
else
{
ddlLocal.Visible = false;
tbLcl.Visible = true;
if (ddlCti.SelectedIndex 0)
{
tbCity.Visible = true;
}
}
tbLcl.Text = "";
tbPin.Text = "";
tbPin1.Text = "";
}
protected void ddlLocal_SelectedIndexChanged(object sender, EventArgs e)
{
tbLcl.Visible = false;
if (ddlLocal.SelectedValue.Length < 1 || ddlLocal.SelectedValue == "0")
{
if (ddlLocal.SelectedValue == "0")
{
tbLcl.Visible = true;
}
tbPin1.Text = "";
tbPin.Text = "";
}
else
{
tbPin1.Text =
Propertywala.Address.GetPincode(long.Parse(ddlLoca l.SelectedValue));
tbPin.Text = tbPin1.Text;
}
}
private void VisibleInputFields()
{
bool isIndian = false;
if (ddlCountry.SelectedItem.Text == "India")
{
isIndian = true;
}
tbState.Visible = (!isIndian);
ddlStt.Visible = isIndian;
ddlCti.Visible = isIndian;
ddlLocal.Visible = isIndian;
tbPin.Visible = isIndian;
tbPin1.Visible = (!isIndian);
if (!isIndian)
{
tbLcl.Visible = true;
tbCity.Visible = true;
}
if (Page.IsPostBack)
{
ddlStt.SelectedIndex = -1;
ddlLocal.Visible = false;
ddlCti.Visible = false;
tbLcl.Text = "";
tbCity.Text = "";
tbPin.Text = "";
tbPin1.Text = "";
tbStr1.Text = "";
tbStr2.Text = "";
tbState.Text = "";
}
}

}
Apr 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matt | last post by:
I always see the term "postback" from ASP book, but I am not sure if I fully understand the meaning. Here's my understanding so far, please correct me if any mistakes. Here's a typical html...
8
by: needin4mation | last post by:
I understand this is a asp.net group, but thought I would post this here for comments. I admit I have used this post in another group, but it has less traffic. Here's to hoping I'm just blind to...
1
by: Mihir | last post by:
Hi There, I've problem while I submit a button where I used AJAX, I created simple page which will search the customer name from database using AJAX. Once I search customer ID i need to search...
1
by: Louis-Philippe Dumoulin | last post by:
Hi, I have the following problem in asp 1.1. On my web page, when I click on a menu, a postback is generated. On the post back, I create dynamically with LoadControl a WebGrid (from InterSoft)...
1
by: codefragment | last post by:
Hi I have asked this on the official asp.net forums but no luck so thought I'd try here Assume you have a page with a filter control and a grid view and many other controls on it. When the...
6
by: HockeyFan | last post by:
I'd like to have an AJAX textbox that after the user fills in, will auto-fill another textbox on the page without having a postback occur. It doesn't have to do any filtering or any other thing...
3
by: radix | last post by:
Hello, I have a aspx page with ajax scriptmanger update panel etc. I also have public string variables on the aspx page. Whenever postback happens from Ajax update panel, at server side all...
5
by: BM | last post by:
I have a question that seems like it should have a simple answer, but I can't seem to find it by searching... Anyway, I'm trying to capture the IsPostBack event when I select an item within an...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.