.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Show MessageBox of ValidationSummary from Codebehind

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :ASP.Net


 I want to Show MessageBox of the ValidationSummary (ShowMessageBox="true")  from Code behind. Below is the code i used.Any tips.

Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
 Dim blnFlag = callmethod()
 If Not blnFlag Then
    ValidationError.Display("Place error message here")
 End If

End Sub

Public Class ValidationError
    Implements IValidator
    Private _errorMessage As String = String.Empty
    Private _isValid As Boolean = False
    Public Shared Sub Display(ByVal message As String)
        Dim currentPage As Page = TryCast(HttpContext.Current.Handler, Page)
        currentPage.Validators.Add(New ValidationError(message))
    End Sub
    Public Sub New(ByVal message As String)
        ErrorMessage = message
        IsValid = False
    End Sub
    Public Property ErrorMessage() As String Implements System.Web.UI.IValidator.ErrorMessage

View Complete Post

More Related Resource Links

MessageBox.Show doesn't in 64-bit Windows 7

Sanity check - MessageBox.Show dialogs don't appear when I run my WPF app on 64-bit Windows 7, but work fine on 32-bit Windows 7. Am I forgetting to do something?

MessageBox.Show() always on screen center


Hi everyone, 

I use a MessageBox in one of the methods in my MainWindow.xml.cs, 

Although i set the Window paramter to "this", the message box always show up on the screen center no matter where the MainWindow is 


Any idea on that?

Problems with AddPastingHandler and MessageBox.Show



Im trying to interrupt the paste event in some UI elements in my application to be able to change the data actually pasted.

Basically i do this like:

DataObject.AddPastingHandler(memo, new DataObjectPastingEventHandler(CheckPasteFormat))

public void CheckPasteFormat(object sender, DataObjectPastingEventArgs e)
  DataObject d = new DataObject();
  d.SetData(DataFormats.Text, "Chaning pasted text");
  e.DataObject = d;

This works until i try to display a new window (or as test Messagebox.Show) inside CheckPasteFormat, then I get this error:

Dispatcher processing has been suspended, but messages are still being processed.

I googled it, and after a while found the following solution:

DataObject.AddPastingHandler(memo, (o, e_arg) => Dispatcher.BeginInvoke(new DataObjectPastingEventHandler(CheckPasteFormat), o, e_arg));

First it seemed like a perfekt solution. I am now able to show Windows/dialogs and MessageBoxes, but i discovereed that the

MessageBox.Show error


If I have .NET 3.5 SP1 and use MessageBox.Show(), everything works fine.

However, if I dont have .NET 3.5 SP1, I need to detect that and print a pop up on the screen. How do I do that? If I use MessageBox.Show() in that case, I get an exception error.

Can we have colored error message in c# messagebox.show method


I am new to c# i need some help regarding messagebox.show method.

is it possible to give color to the error message,change the font of the error message.

or customise the messagebox like provide some background image on the messagebox.

GridView control to show master-child or master-slave data, written in c#, asp.net

I previously made a master slave datagrid using Visual Studio 2003 .Net (original article) that would allow users to show data to clients using collapse and expand features. These features however did not carry over to gridview for many users. This tutorial will explaing how to create a collapsable/expandable gridview in frameworks 2.0 and higher

Show grand total running total in GridView Footer

In many scenarios we need to display Running total as well as Grand total in GridView footer. In this post i will try to explain in an easy way that how we can display running total & Grand total in a GridView footer combindly. To explain this solution using an example here i use a sales order report. The report contains all sales order amount in a tabular way. I will use a GridView to display sales order amount and use GridView footer to display Running total & Grand total. Let we have a customer table with id and name column plus an orders table with OrderID,CustomerID,OrderDate & Amount. Now our goal is to show all customers order with amount as well as page wise running total & grand total. Note that running total is necessary when you enable paging in a GridView where as Grand total is always you can consider.

Inserting personal error message in ValidationSummary



I am creating a web form that requires a lot of validation. I use many of the validation control in asp.net already like RequiredFieldValidator and CompareValidator. 

My Problem: after my custom validation for the value entered return an error message, and I pressed enter key when the field is empty, my custom error message is overlapped by my ValidationSummary. 

Setting my custom error to visible = false on button click also does not seem to work as it requires for me to enter the value first.

This made me think, is there a way to insert my custom validation inside the ValidationSummary as an error message like for other validation control?

Thanks in advance

datalist image slide show problem


hi friends

i am binding  images dynamically(back end)for a datalist .iam applying a slideshow for it .I am getting a problem to apply slideshow for dyanmically binded images.If the define in a div statically it working perfectly

for example pls go through my code below:

<script type="text/javascript">
$(document).ready(function() {
        fx: 'scrollLeft' // choose your transition type, ex: fade, scrollUp, shuffle, etc...

<div class="slideshow">
        <img src="images/30_dummy.jpg" width="200" height="200" />
        <img src="images/aquarius.gif" width="200" height="200" />
        <img src="images/star.gif" width="200" height="200" />
        <img src="images/the-proud-indian-flag-1.jpg" width="200" height="200" />

I above code works perfectly and the slide show e

create user wizard login error message dont show in a message box?




i am using create user wizard and capturing other information within content template when a new user

registers. Some of the textboxes are binded to required field validators.


there is a validation control on the page and ShowMessage box is True.

If they dont complete some of the text boxes then the message box pops Up with the error message.

It does not however include information errors like "User already exists" or Email address already exists

from the create user wizard membership  UserName and Password Textboxes


is it possilbe to hook all of these up so I get one message box with all errors including membership ones?




Can't get an Icon to show for Desktop shortcut and Program Menu



I've created a SetupWizard, but can't get it to show the Icon for the shortcut on desktop and program menu. The installation goes fine without any errors, the only problem is the icon.

I've made a shortcut of my exe file in the Application Folder and dragged the shortcut to the Desktop folder, then on the shortcut properties, I assigned it an icon picture located in Application Folder.

Any suggestions will be very much appreciated.


Why show only one record?



// Update these variables to values whatever you are storing in your table
        // If you are storing as CARD NUMBER, update this Card Number Attribute Name to CARD NUMBER
        string strCardNumberAttributeName = "Credit card number";
       // string strCardTypeAttributeName = "1";
        string strExpiryDateAttributeName = "Expiry date";
        DataTable dtPaymentDetails = new DataTable();

        string queryString = "SELECT tbl_Payments.PaymentId, tbl_PaymentDetails.AttributeName, tbl_PaymentDetails.Value, tbl_Payments.PaymentType FROM tbl_Payments INNER JOIN tbl_PaymentDetails ON tbl_Payments.ID = tbl_PaymentDetails.PaymentId WHERE ATTRIBUTENAME IN ('" + strCardNumberAttributeName +
                                   "','" + strExpiryDateAttributeName + "') ORDER BY PaymentId";

        string connectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;" +
                                           "AttachDBFilename=|DataDirectory|\\BurnbetDatabase.mdf;User Instance=true";
        using (SqlConnection connection = new SqlConnection(connectionString))
            SqlCommand command = new SqlCommand(queryString, connection);
            SqlDataReader reader = command.ExecuteR

Modify Menu adapter to show selected


Hey, I need some help modifying the menu adapter code to give child <ul> elements a class value indicating that the parent is selected. It should render like this:


< ul class="AspNet-Menu">
	< li class="AspNet-Menu-WithChildren  AspNet-Menu-ChildSelected">
		< a href="/rockit/admin/Default.aspx" class="AspNet-Menu-Link  AspNet-Menu-ChildSelected">
		< span>Mypage< /span>< /a>
			< ul class="AspNet-Sub AspNet-Sub-Selected">
				< li class="AspNet-Menu-Leaf  AspNet-Menu-Selected">
					< a href="/rockit/admin/Default2.aspx" class="AspNet-Menu-Link  AspNet-Menu-Selected">
					< span>Test< /span>< /a>
				< /li>
				< li class="AspNet-Menu-Leaf">
					< a href="/rockit/Default3.aspx" class="AspN

Extreme ASP.NET: Codebehind and Compilation in ASP.NET 2.0


As I write this column, the release candidates of the Microsoft® .NET Framework 2.0 and Visual Studio® 2005 have just come out, and by the time you read this, they will both already be on the shelves. It feels like it's been a long time coming.

Fritz Onion

MSDN Magazine January 2006

Cutting Edge: Using Windows Hooks to Enhance MessageBox in .NET


It's fairly safe to assume that all programmers working in Windows® environments are familiar with MessageBox. The MessageBox function displays a message through a popup dialog box and lets programmers add dialog buttons and icons to the message to improve user feedback.

Dino Esposito

MSDN Magazine November 2002

ModalPopup/UpdatePanel from codebehind, inconsistent behavior onClick


First post bear with me please:

I have a simple form with a list of linkbuttons, each fires the same onclick event which sets an indicator image.  I have a dummy button with style="display:none" which I have set as the TargetControlID of the modal.

onClick event from the imagebutton, the modal is shown via modal.Show().  The cancel button inside the modalpopup fires an event which turns off the indicator image and hides the modal via modal.Hide(). 

The events fire perfectly, it's very simple!  Although after doing some testing I noticed the modalpopup is not presented after the 6-10th cycle of clicking the open event, then clicking cancel.  The grey background appears but it is behind the main panel and the modal is either presented behind this or is just simply not displaying. 

I spent hours researching various methods, implemented the CancelControlID to see if it was somehow tied to my call of modal.Hide() that fails.

This occurs with an updatepanel only.  The behaviour is much cleaner this way, so I would hope to be able to implement this.  I have basically eliminated everything but these two events!  Please help

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend