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

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

Custom Validator on DDL&Textbox values

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
I need to write a 2 custom validators that works as follows: I have a formview (Formview1) with an EditItemTemplate. The validators need to validate values in "DropDownList1" and a textbox called "EndUserGUIDTextBox" If the value in DDL1 is ("Assigned" or "Assigned to End User") and the value of EndUserGUIDTextBox is ("unassigned" or "pending" or NULL) then I need a validator to fire and return {"GUID must be assigned when status is" & DLL1 value}. If the value in DDL1 is ("In Stock" or "In Repair") and EndUserGUIDTextBox is NOT ("unassigned" or "pending" or NULL), then I need a validator to fire and return {"GUID must not be assigned when status is" & DLL1 Value}. The validators needs to run and show in the formview when the UpdateButton in my Formview is clicked. I'm doing this in VB. Real noobie here! All help appreciated. Thanks,

View Complete Post

More Related Resource Links

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

how to bind Dropdownlist based on textbox values



I have one drodownlist which show data based om textbox values...

Let us consider i have 

Select Name from table1 where Type IN(@typ)

here @typ is textbox values

here for example textbox will have some thing like this L1,L2,L3..

How to filter Name based and shown in drodownlist based on this L1,L2,L3(on textbox)..

Help me in this

How can I set the value of a Custom FormField textbox to an ASP Textbox's value?


Info: WSS 3.0 MOSS 2007 Windows Server 2003, SQL 2005.

I created a new ASPX page on one of my sites, and configured it the following way:

SQL Datasource to my own database and a series of drop down boxes that help the user configure a part number. Once that part number is created, they click the submit button to submit it to my separate database. I also have a custom SharePoint list that I would like to add that part number to so that it generates emails and does other workflow related tasks.

How can I copy the text that is within the part number asp:textbox and throw it into the SharePoint:FormField Textbox so that it can be submitted to SharePoint?

I have C# code within the page that handles the ASP side of things, but I can't seem to reference the ff1{$Pos} id of the FormField. If I had to guess, i'd need to create some code that injects the javascript that gets reference to the FormField by Field Type and Field Name. But...I'm not entirely sure how to do that.

Any help is appreciated, thank you!

How do you create a custom BDC data field that allows for multiple selected values?

I need help creating a custom data field using the BDC column as a base.  We need to allow for multiple selected values instead of just a single one.  I can't find anything on the net which shows how to do this.

Retain DropDown,TextBox's previously selected values after redirected from another page.


 Hi People, How are you all doing?

I have 2 pages one is SearchPage & It has DropDowns, textboxes to specify the search criteria. From the search result the user is redirected to another page when he clicks the hyperlink in the search result  where he fills in the information and again redirected to SearchPage. Now the SearchPage is posted back with no state i just want to retain the search criteria and display when user comes back. Please give me some suggestion how to get this done. I've used ViewState to save the values and check them in Page_Load but they are null.   



 Update: I've come up with this code. But the problem is The values are being retained but the Button_Click event is not being handled properly. When i Check the code even after this "DropDownList1.SelectedValue = Session["Name"].ToString();" DownList1.SelectedValue is EMPTY"" samw with DropDownList2 . please Suggest something


    protected void Page_Load(object sender, EventArgs e)
        if (IsControlsEmpty())
            if (SessionExist())
                DropDownList1.SelectedValue = Session["Name"].ToString()

Custom Validator


I need to validate a field that depends from a selection of a dropdownlist.

Like, if on dropdown the selected value is 'N' then validate. But it it's 'S', ignores validation;

Is there a way to do this with custom validator ??

I tried but, it's not working.

function chkEndereco(source, args){
   var cmbOnde = $('select[id$=comboOnde]');
   if(cmbOnde.val() == 'N')
      args.IsValid = (args.Value == '')
   if(cmbOnde.val() == 'S')
     args.IsValid = true

<asp:TextBox ID="Endereco" name="endereco" runat="server" AutoCompleteType="none" autocomplete="off" />
                                    <ajaxToolKit:TextBoxWatermarkExtender ID="wmEndereco" runat="server" TargetControlID="Endereco" WatermarkText="Endereço (rua, avenida, etc)" />
                                    <asp:RequiredFieldValidator ID="rqEndereco" runat="server" ErrorMessage="Ops! Faltou o endereço." EnableClientScript="true" ControlToValidate="Endereco" Display="None"/>
                                    <asp:CustomValidator ID="crqEndereco" runat="server" ErrorMe

Giving Custom Colors for Graph values in SSRS2000


Hi All,

        I am stuck here with the color for the graph values i want to give custom colors for each values present in the graph, is it possible in SSRS2000.

 Problem Statement : Suppose if i want to display two data fields as bar graph

                                 Data Fields are : Vegetable Count and Fruits Count

                                          I want Vegetable count to be in Blue Colour and I want Fruits count to be in green colour.

Any help would be appreciated.

Thanks in advance.

Anish Shenoy

Creating a Validator class for a custom activity

I created a new Workflow Activity Library and then added a new Activity called BindForm2Activity. After that I added a new class called BindForm2Validator and then placed an attribute to the BindForm2Activity to link it to the validator class.   Here is the code for each of the classes:   BindForm2Activity.xoml.cs: Code Snippet   using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Collections;using System.Drawing;using System.Linq;using System.Workflow.ComponentModel.Compiler;using System.Workflow.ComponentModel.Serialization;using System.Workflow.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Workflow.Runtime;using System.Workflow.Activities;using System.Workflow.Activities.Rules; using FormsCollection;using Utils; namespace ActivityLibrary{    [ActivityValidator(typeof(BindForm2Validator))] public partial class BindForm2Activity : SequenceActivity {        public static DependencyProperty FormToBindProperty = System.Workflow.ComponentModel.DependencyProperty.Register("FormToBind", typeof(FormsCollection.Form2), typeof(BindForm2Activity));         [Description("Form to bind a datasource to it ")]        [Category("BindForm2ToDataSource")]        [Browsable(true)]        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]        public FormsCollection.Form2 Form

How do you add duplicate fields to a SSRS custom report and receive differtent output values.

I have built a custom report in SSRS 2008 using fields for supplier and customer.   I have added a Parent Row Group using the Supplier field for the group expression and used the Customer Details as my child details group. This returns a list of all customers for each supplier.   (Supplier | = Customer details ( Name, Dob etc.)   How would I add an additional Supplier field to the customer details returning only values for other Suppliers used by a customer, not the value of the Supplier listed in the Parent Group?

Custom Sort Values in a Group

Hello, I have a dataset from cube. Please assume the data is similar to below State  Product Sales CA      Bikes    100           Cars     10 MN    Trucks    16 GA    Cars      10        Boats       25   This is represented in a simple tablix and a group is formed on the State. I want to provide a custom sort order on the grouped field lets say i want GA first, followed by CA and then MN. How do i design such a solution? Thank you in advance for your advice.      

Passing values from web page to custom security trimmer in SharePoint 2010

Hi, In SharePoint 2007 we had a custom security trimmer that implemented ISecurityTrimmer interface. We also had a custom webpart used for search. Now, using HttpContext we passed values from the webpart to security trimmer with additional info needed to trim the results. It worked since trimmer was executed in the same w3wp process as webpart. Now in SharePoint 2010, the architecture for ISecurityTrimmer2 has changed, as it's executed in search process (other w3wp) - not the webpart w3wp so it has no access to the HttpContext. Question is: how to pass custom data, in form of the string, to a security trimmer when search is done from custom code in webart?

custom validator

Is it possible to pass the maximum character length to validateCharacter, rather than just have it set in stone.<asp:CustomValidator ID="ValCharacter" ControlToValidate="txtCharacter"  OnServerValidate="validateCharacter"  Text="Too many characters" runat="server" Display="Dynamic" />        Protected Sub validateCharacter(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)        Dim iChars As Integer = 500        If args.Value.Length > iChars Then            args.IsValid = False        End If    End Subthanks.

keep values in textbox in gridview whilst paging

Hi,   I have a gridview in my webpage which has paging enabled. There are around 5 textboxes in a row and when I enter some text and then move to another page and move back to the page I entered the values in, they are not lost. I have enabled the viewstate in the gridview. I have implemented a datatable to my grid which should hold the values in the viewstate. This worked before I added paging. Please can someone offer some advice as to how I can maintain the values in textboxes whilst moving between different pages? I have tried searching it but I can't seem to find any relevant info.   Thank you very much.

Validating Textbox for Numeric Values

I want to validate a textbox that only a numeric currency value can be put into it, for example 0.00. I thought the following code was correct but it doesnt seem to wrk, its causing an error on my page and when I remove it the page is fine, it doesn't actually give exact details of the error on the page just says "syntax error" in the browser that is all.<asp:CustomValidator runat="server" ErrorMessage="Please enter a numeric value for Night Rate in the format of 0.00" ID="NightRateNum" ControlToValidate="txtNightRate" Text="*" ClientValidationFunction="^\d+(\.\d\d)?$"></asp:CustomValidator>Would appreciate if any can tell me where I went wrong Thanks

The sum value is not reflected immeditly in the textbox, using my custom code.

Hi,    I created a custom expense form, i used reperting table and i has column named "Total" in the repeating table. At the footer of the repeating table i add a texbox, that hold Grand total of the "Total" column from the repeating table. To get the grand total i used to get the texbox value and sum it and assign it to another control. It work fine in Infopath form. But when i open it in Web browser, the updated value is not shown immeditaly, when i click on insertitem link a new row get added.Why it happen in web browser.?

Custom Validator inside PasswordRecovery...

Hello,   I am using a PasswordRecovery Control and have changed one of the validators to a custom Validator, however, OnServerValidate neer seems to get called.   Can someone tell me how to get the OnServerValidate to work correctly?   Thanks.

Custom membership provider not returning values from my web.config


I created a custom membership provider in my ASP.NET 4.0 web site, stored  in App_Code, and referenced in my web.config.

However, it doesn't appear to be pulling values out of web.config during initialization.

The code was taken from http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider, and the only modifications were changing "connectionStringName" here to the name of my connection string:

    Dim ConnectionStringSettings As ConnectionStringSettings = _

The connection string always comes back as nothing in this line:

    If ConnectionStringSettings Is Nothing OrElse ConnectionStringSettings.ConnectionString.Trim() = String.Empty Then
      Throw New ProviderException("Connection string cannot be blank.")
    End If

No matter what I change the password format to in web.config, the default value here is always used:

    Dim temp_format As String = config("passwordFormat")
    If temp_format Is Nothing Then
      temp_format = "Has
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