MVC :: Accomplish The Same Behavior For Both Custom And Default Validations
Apr 21, 2010
When I am using one of the default validation attributes, like [Requeried], and try to submit the form that is in an invalid state some 'magical' happens and the submit is canceled. I can even click 100x that not a single server request is made.On the other hand, I can't accomplish this behavior when I am using a custom validation attribute. Although my form was in an invalid state, a request is sent to the server anyway.I took a look at the "MicrosoftAjax.js" and "MicrosoftMvcValidation.js" but I am totally noob when it comes to Javascript.How can I accomplish the same behavior for both custom and default validations
View 16 Replies
Similar Messages:
Mar 1, 2011
i cant seem to selectively disable serverside validation using annotations. Data annotations and unobtrusive validation is an awesome feature and has worked out great for us thus far but trying to localize it has been fruitless.
Basicly i have a property in a model object like this (it wraps a DTO)
[Code...]
i can change the output text for things like data range, required, string length etc. but simple stuff like "this field has to be a number" seems hidden away.
View 5 Replies
Nov 20, 2010
I have index.aspx , index.html and another mvc application. I found mvc application takes the priority to execute. I want to know how to determine the sequence.
View 1 Replies
Jan 12, 2010
In a base class object, I have an overridable subroutine that I would like all derived objects to have the ability to include. However, they don't have to, and if it's not necessary for them to use it, I don't want them to be forced to declare it. To enforce this, I've left the default behavior empty. For example, here's my whole sub:
Protected Overridable Sub MySubroutine(ByVal someObject As Object)
End Sub
Is this bad practice? I don't want to declare it as MustOverride, but I don't want default behavior. Is there a "better" way of doing this, or is this perfectly acceptable? I don't want to be that hack programmer... just trying to learn :)
View 2 Replies
Feb 25, 2010
In forms I need to do custo validations. Like if use select radio button that he is residing on current address for more than 3 than previous residance fields are optional but if he select (radio button) that he is residing on current address for less than 3 years than previous address fields should be requried. Requirment is to do these on client side.
how this can be done. Secondly can there be some way we just disable a validation group and all validations in this group may be turned to disabl ?
View 1 Replies
Jan 3, 2011
Is there a way I can override the default scrolling using when SetFocusOnError = true? Right now it pops the user up the page so that the top of the control is at (0,0). The problem is that our labels are above the controls, so the user can't see the label without scrolling up a little more. I'd like to make it center the control vertically instead, and ideally even do a nice smooth jQuery slide up. I tried like this but it didn't work (never gets fired):
function WebForm_AutoFocus(obj) {
elem = document.getElementById(obj).scrollTop() - 200; //Go to 200px above where the element is
$('html, body').animate({ scrollTop: elem }, 350)
}
View 1 Replies
Mar 1, 2010
I an expanding on the HotGridView control (http://msdn.microsoft.com/en-us/magazine/cc163612.aspx). During testing I noticed the "AutoGenerateCheckBoxColumn" behavior was returning true even if the user did not specify the a value in the markup but I expect it to return False if not value is supplied by the user - can anyone shed some light on why the AutoGenerateCheckBoxColumn is always true if not explicitly set to False in the markup?
[Code]....
View 1 Replies
Jun 7, 2010
I have created a custom control and I intended to assign some attributes which is not necessary to implament.
I also assign default value for them but I am getting System.NullReferenceException error.
Here is my CC's attibute code;
public class ApplicationModule2010 : CompositeControl
{
[DefaultValue(true)]
public bool AppFormOnLine { get { return (bool)ViewState["AppFormOnLine"]; } set { ViewState["AppFormOnLine"] = value; } }
...
also ı have written the below code for another attribute but its default value doesn't work as well;
[DefaultValue("Application is Offline ! Define an offline Text insted of this text !<br/><br/>TugberkUgurlu.Com")]
public string OfflineText { get { return (string)ViewState["OfflineText"]; } set { ViewState["OfflineText"] = value; } }
What am I missing here ?
View 1 Replies
Nov 15, 2010
I have some (probably very basic) questions about developing custom controls. I am wanting to derive a set of button controls, and the first one I have started on is a "DeleteButton", that has a additional property (DeleteConfirmationText) that is built into the OnClientClick attribute. To get that added, I overrode the Render method as follows:
[Code]....
This all works well. Now, I will add some logic to make sure that there is some text in the DeleteConfirmationText property, but that isn't the intent of my question.
What I am also wanting to do is to override some of the default property values, so I added that to the default constructor:
[Code]....
Now, in the designer in VS2008, and I look at the properties for the control, there isn't a default value shown in the "Properties" section, and the Causesvalidation still shows the underlying classes default value of "True". As well, in design mode, where the GridView control that containse my DeleteButton control would be displayed, there is an error box "There was an error rendering the control. 'Are you certain you want to delete this attorney?' cound not be set on property 'DeleteConfirmationText'. Here's the markup where I am defining the deletebutton control:
[Code]....
What am I doing wrong?
View 5 Replies
Aug 1, 2010
n a grid view I have a column named REQUIRED which has a value of either 0 or 1.I added a checkbox templated field to show the above as checked or unchecked instead of0 or 1. I decoded the value Y or N to 1 or 1 in the sqldatasource
<asp:GridView>
<asp:CheckBoxField DataField="BOARD" ReadOnly="True">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
heckBoxField>
When I tried to add the following "Checked='<%# Eval("BOARD") %>' it does not like it and gives an error.How do accomplish the same for the above checkbox field and the exact syntax to be used
View 5 Replies
Sep 28, 2010
Need a way to write in c# something that we can query access database and send out individual emails using 3 seperate templates based on the users selection. basically users have been signing up to receive an email later in the year.. there are 3 possible email templates that are designed and will be sent based on what the user selected. So when the time comes, we need to take and query the access database and send an email to the user with the template they picked.
I see alot of software packages, but cost more than what we can spend(no budget), so we need something simple and free that can be scheduled to send on certain day and time. Or if there are any tutorials on creating something to do this, doesnt need to be fancy
View 7 Replies
Apr 20, 2010
I am using a treeview in a web part that I am writing. When the user moves the mouse over the +/- icon in the tree, a tooltip is shown: "Expand FolderName" or "Collapse FolderName". Because there is a requirement to localize this web part, I need to be able to set a localized tooltip, replacing the english one. (That english string appears, even when the machine is running a Chinese OS.)how to accomplish this localization?
View 1 Replies
Aug 27, 2010
Currently i have membership and roles setup on my site. Now what is my next step to get more specific control.
Based on what i hav now, i have my pages setup so they are visible or not and links not visible and so on. But now on a more detailed level, say im setup as a user. As a user my default permissions is just to view data.. no editing. But say someone was let go, now instead of granting me full access to everything, i need to be able to go in and provide more permissions to the account.
Example:
Admins:
Add Users
Modify Users
Delete Users
Users:
View Users Detail (only the person that is logged in)
Since the the user that was let go was an admin. They had all the other options, but as a temporary thing, we need to be able to add say permission "Add Users" to the individual user account.
To accomplish this type of control, what do i need to look at to accomplish such a setup?
View 3 Replies
Jun 16, 2010
I know you can add defaultValues using the web.config like this:
<profile>
<properties>
<add name="AreCool" type="System.Boolean" defaultValue="False" />
</properties>
</profile>
but I have the Profile inherited from a class:
<profile inherits="CustomProfile" defaultProvider="CustomProfileProvider" enabled="true">
<providers>
<clear />
<add name="CustomProfileProvider" type="CustomProfileProvider" />
</providers>
</profile>
Heres the class:
Public Class CustomProfile
Inherits ProfileBase
Public Property AreCool() As Boolean
Get
Return Me.GetPropertyValue("AreCool")
End Get
Set(ByVal value As Boolean)
Me.SetPropertyValue("AreCool", value)
End Set
End Property
End Class
I don't know how to set the default value of the property. Its causing errors because without a default value, it uses an empty string, which cannot be converted to a Boolean. I tried adding <DefaultSettingValue("False")> _ but that didn't seem to make a difference.
I'm also using a custom ProfileProvider (CustomProfileProvider).
View 2 Replies
Feb 2, 2010
The select and show details do not meet my requirement, I need them on the page all together.Is there a simpler approach then datalist inside repeater?
View 3 Replies
Feb 10, 2011
I can create a custom control with a default value:
private bool exclue = false;
public bool Exclude { get { return exclue; } set { exclue = value; } }
I can Create the same thing with a nullable property:
private EntityStatuses? status = EntityStatuses.Active;
public EntityStatuses? Status { get { return status; } set { status = value; } }
But how can i then set the property to null in markup when using the custom control?
<MyControls:Control ID="Con" runat="server" Status="?" >
View 3 Replies
Jul 15, 2010
How does one create new sites in your own custom directory? Can it be added as a feature?
View 2 Replies
Jan 15, 2010
I would like to call a method in the ObjectContext which returns EntityCollection and have it sorted the way I want by default. For example, Imagine I have the following Category table/class:
CategoryID (PK)
Name
ParentID (FK_Category) foreign key
pointing to CategoryID itself.
(This table is the base for a tree structure of Categories and SubCategories)
Now, in my data model, the public partial class Category : EntityObject has a property which returns all Categories that have ParentID==CategoryID, in other words, EntityCollection<Category> SubCategories.
Alright, now i want to show in my page all the Categories and SubCategories by using Repeater:
<asp:Repeater ID="rptSubCategories" runat="server">
<ItemTemplate>
<%# Eval("CategoryID") %> - <%# Eval("Name") %>
<asp:Repeater ID="rptSubCategoryCategories" runat="server" DataSource='<%#Eval("SubCategories")) %>'>
<ItemTemplate>
<%# Eval("CategoryID") %> - <%# Eval("Name") %>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
Then in code behind, I set the DataSource:
IList<Category> categoryList = new CategoryProvider().GetAll();
rptSubCategories.DataSource = categoryList;
rptSubCategories.DataBind();
Simply and everything works! Except that, rptSubCategoryCategories doesn't gives sorted Categories by Name. The only way I found to do it, is to change its DataSource from:
DataSource='<%# Eval("SubCategories")) %>'
to:
DataSource='<%# ((EntityCollection<Category>)Eval("SubCategories")).OrderBy(p => p.Name) %>'
but I wish I could do something else to have a default sorting so i don't need to call the OrderBy. Something like Attributes like we do in DynamicData, following the tutorial at [URL] Setting the default sort column of an Entity with DisplayColumnAttribute. Unless somebody tells me it's impossible what I want to do.
Using .NET 4.0 BETA 2
View 1 Replies
Feb 8, 2010
I have the following code for my radiobutton selectedindexchange, i have a hidden field in the gridview with the cid( which is the unique id for the records, the last column in the gridview is the radiobutton and i want to update my record with the value of that radiobutton.
[Code]....
View 10 Replies
Apr 24, 2010
I am working with RSA Algorithm recently.
I want to use RSACryptoProvider for this purpose.
But i want to use my custom Key instead of default key
for example my public Key =(187, 7)
and my private key=(187,23)
how can i pass my public and private key at RSACryptoProvider
View 2 Replies
Apr 23, 2010
I am trying to use a second (custom) table to extend my users profile info. This table is in the same database as the 'aspnet_Users' table but has a different name. I create a FK relationship between the 'aspnet_Users' table and my custom table. Here is my web.config code:
<profile defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ConString_SQLConnectionString"
applicationName="/" />
<add name="MyCustomProfile"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ConString_SQLConnectionString"
applicationName="/"
table="MyProfileTable_Employees" />
</providers>
<properties>
<group name ="MyProfileInfo">
<add name="FirstName" type="string" defaultValue="[null]" customProviderData="FirstName;nvarchar" provider="MyCustomProfile" />
<add name="LastName" type="string" defaultValue="[null]" customProviderData="LastName;nvarchar" provider="MyCustomProfile" />
<add name="EmployeeNumber" type="int" defaultValue="[null]" customProviderData="EmployeeNumber;int" provider="MyCustomProfile" />
</group>
</properties>
</profile>
I have the table "MyProfileTable_Employees" poplulated with data the 'userid' matches to the aspnet_Users table. In my web application (vb), when I type in Profile.MyProfileInfo, there are no custom fields. Actually, when I type profile., there are no profile related entries. What am I missing here? Am I miss-interpting what a custom profile provider is?
View 2 Replies
Jan 10, 2011
I have created a user control that has a gridview. During binding I set some common properties like height and width. To do so, I have created public properties. I have created the public property so that user can also set the height and width themselves. But if user didn't specify then I use my defaults.
My problem is that user settings are always overridden by my default settings. I want to set the default values as the control is rendered on the page and then if user apply his settings then it shold override. Which event/method is best on user control to jandle such scenario? Where should I write the code to call my default settings so that it is first thing that happens? What is the user control life cycle?
View 2 Replies
Jul 26, 2010
i have the following property which takes an IP address as its value and defined in my custom config section as follows and To validate the IP address i am using a Reg expression.
[ConfigurationProperty("SMTPServer", IsRequired = true, DefaultValue = "0.0.0.0")
View 1 Replies
Nov 3, 2010
How to set default Height/Width property value of Composite control
[Code]....
View 3 Replies
Aug 22, 2010
1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like
SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.
Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).
2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query
(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).
If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.
View 11 Replies