Welcome to Dream.In.Code
Become an Expert!

Join 150,047 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,678 people online right now. Registration is fast and FREE... Join Now!




"Invalid postback or callback argument" error

 
Reply to this topicStart new topic

"Invalid postback or callback argument" error

PsychoCoder
28 Feb, 2008 - 09:44 PM
Post #1

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Im getting this weird error all of a sudden and dont know where its coming from. All I did was add a DropDownList populated with accepted email domains instead of the user having to type the whole thing out, they type in their username then pick their domain, seems simple enough. In my button click I have:


csharp

protected void cmdSubmit_Click(object sender, EventArgs e)
{
string email = Email.Text + domain;
Response.Write(email);
Response.End();
reqEmail.Validate();
reqPassword.Validate();
Session["Email"] = email
DataSet contacts = new DataSet();
importer.EmailAddress = email;

importer.Password = Password.Text;
importer.TimeoutValue = 120;
importer.QNumber = 1;
contacts = importer.ImportContacts();
if(importer.IsSuccess)
{
contactsList.Visible = true;
repContacts.DataSource = contacts;
repContacts.DataBind();
repContacts.Visible = true;
buttonsPanel.Visible = true;
ErrorMessage.Text = importer.ReturnMessage;
ResultLabel.Text = repContacts.Items.Count + " records returned";
ResultLabel.Visible = true;
cndGetContacts.Enabled = false;
SetView(ActiveView.StartOver);
}
else
{
ErrorMessage.Text = importer.ReturnMessage;
}
}


Nothing fancy there, the only thing that's changed is the new DropDownList, and concantenating the email TextBox text with the selected item from the DropDownList, which looks like:


csharp

protected void supported_domain_SelectedIndexChanged(object sender, EventArgs e)
{
domain = supported_domain.SelectedItem.Text;
}



For populating the DropDownList I use this code:


csharp

try
{
DataSet domains = util.BuildDataSet(Server.MapPath("supported_domains.txt"), "Domains", "\t");
supported_domain.DataSource = domains;
supported_domain.DataTextField = domains.Tables[0].Columns[0].ToString();
//supported_domain.DataValueField = domains.Tables[0].Columns[0].ToString();
supported_domain.DataBind();
}
catch
{
Response.Write(util.Message);
}



The BuildDataSet method looks like:


csharp

#region BuildDataSet
/// <summary>
/// method to read a text file into a DataSet
/// </summary>
/// <param name="file">file to read from</param>
/// <param name="tableName">name of the DataTable we want to add</param>
/// <param name="delimeter">delimiter to split on</param>
/// <returns>a populated DataSet</returns>
public DataSet BuildDataSet(string file,string tableName,string delimeter)
{
//create our DataSet
DataSet domains = new DataSet();
//add our table
domains.Tables.Add(tableName);
try
{
//first make sure the file exists
if (File.Exists(file))
{
//create a StreamReader and open our text file
StreamReader reader = new StreamReader(file);
//read the first line in and split it into columns
string[] columns = reader.ReadLine().Split(delimeter.ToCharArray());
//now add our columns (we will check to make sure the column doesnt exist before adding it)
foreach (string col in columns)
{
//variable to determine if a column has been added
bool added = false;
string next = "";
//our counter
int i = 0;
while (!(added))
{
string columnName = col;
//now check to see if the column already exists in our DataTable
if (!(domains.Tables[tableName].Columns.Contains(columnName)))
{
//since its not in our DataSet we will add it
domains.Tables[tableName].Columns.Add(columnName, typeof(string));
added = true;
}
else
{
//we didnt add the column so increment out counter
i++;
}
}
}
//now we need to read the rest of the text file
string data = reader.ReadToEnd();
//now we will split the file on the carriage return/line feed
//and toss it into a string array
string[] rows = data.Split("\r".ToCharArray());
//now we will add the rows to our DataTable
foreach (string r in rows)
{
string[] items = r.Split(delimeter.ToCharArray());
//split the row at the delimiter
domains.Tables[tableName].Rows.Add(items);
}
}
else
{
throw new FileNotFoundException("The file " + file + " could not be found");
}

}
catch (FileNotFoundException ex)
{
_message = ex.Message;
return null;
}
catch (Exception ex)
{
_message = ex.Message;
return null;
}

//now return the DataSet
return domains;
}
#endregion



And finally is a screenshot of the error Im receiving, anyone got any ideas? I know Ive seen this error before but cant for the life of me remember how I solved it.

Attached Image

This post has been edited by PsychoCoder: 28 Feb, 2008 - 10:13 PM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: "Invalid Postback Or Callback Argument" Error
28 Feb, 2008 - 10:10 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
This issue is resolved, I had to add EnableEventValidation="false" to my @Page directive.
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: "Invalid Postback Or Callback Argument" Error
28 Feb, 2008 - 10:15 PM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Though this issue is resolved I do have a question bout a piece of code I posted in the OP. My DropDownList's SelectedIndexChanged Event doesn't seem to be doing what I want it to do:


csharp

protected void supported_domain_SelectedIndexChanged(object sender, EventArgs e)
{
domain = supported_domain.SelectedValue.ToString();
}


That code doesn't change the value of domain, no matter what I select domain is always the value of the first item in the list?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:09PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month