|
|
Hi,
I want to have a repeater control on which a row would contain button with + and - sign, when we click on + sign that will display a child that is below this row and makes the text of the button as -, when button with text - is clicked it will hide the item below the row. Just like show and hide functionality on repeater.
Can anybody please help me in this regards any kind of help is greatly helpful. Any code snippet, link or advice would help me a lot.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
|
Hi,
Thanks for your suggestion.
The grid view that you have given me doesn't have editable fields. I am looking something that I can edit, just like in repeater control. Do we have any option for it?
Thanks a lot.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Hello
I am attempting to create a 'Register new user' page in ASP.NET.
I have created an email field for the user to type in his email address, but I am getting errors. The code in my Register.aspx file for the email field looks like this:
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="strEmail" CssClass="col-md-2 control-label">Email</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="strEmail" TextMode="Email" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Email"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The email field is required." />
<asp:CompareValidator runat="server" ControlToCompare="strEmail" ControlToValidate="Email"
CssClass="text-danger" Display="Dynamic" ErrorMessage="Please enter a valid email address." />
The error I am getting is this: 'Exception Details: System.Web.HttpException: Unable to find control id 'Email' referenced by the 'ControlToValidate' property of'.
The reason I have used strEmail is because that is the name of the column in my MS Access database, and it is used by other parts of the site (to resolve forgotten passwords).
How can I correct these errors, please?
Thanks.
|
|
|
|
|
Member 8761667 wrote: ID="strEmail"
Member 8761667 wrote: ControlToValidate="Email"
From MSDN:
This property must be set to the ID of an input control for all validation controls except the CustomValidator control, which can be left blank.
In other words, you need to have the same value in ControlToValidate that you have in ID - in this case, "strEmail".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for your replies.
I only seem to avoid errors if I use the following:
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="strEmail" CssClass="col-md-2 control-label">Email</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="strEmail" TextMode="Email" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="strEmail"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The email field is required." />
<asp:CompareValidator runat="server" ControlToCompare="" ControlToValidate="strEmail"
CssClass="text-danger" Display="Dynamic" ErrorMessage="Please enter a valid email address." />
</div>
In other words, the ID is the same as 'ControltoValidate' (strEmail), but please note that I have no value in this: ControlToCompare=""
I am not sure what that attribute does or how important it is, or even if the code will work! It just seems that I can avoid errors by leaving it blank.
Any advice appreciated!
Blue
|
|
|
|
|
Once again, from MSDN:
Compares the value entered by the user in an input control with the value entered in another input control, or with a constant value.
So the question is, what are you trying to compare your email address to?
For example, if you wanted the user to enter their email address twice, you would have a CompareValidator with its ControlToValidate pointing to the second TextBox , and its ControlToCompare pointing to the first TextBox . The validator would then check that the user had entered the same value in both controls.
If you wanted to make sure the user had entered a specific value, you would leave the ControlToCompare blank, and set the ValueToCompare instead. The validator would then check that the user had entered the specified value.
From the error message, I'm guessing that you want to validate the format of the email address. If that's the case, then you'll probably want to use a RegularExpressionValidator instead[^]:
<asp:RegularExpressionValidator runat="server" ControlToValidate="strEmail"
CssClass="text-danger" Display="Dynamic" ErrorMessage="Please enter a valid email address."
ValidationExpression="^.+@.+$"
/>
The ValidationExpression property uses Regular Expressions[^] to validate the entered value against a pattern. You can find some quite complicated email address patterns on the internet, but most of them have problems with some email addresses. It's generally simplest just to validate that the address contains an "@" character, and has characters before and after it.
You should probably spend some time reading about validation in ASP.NET - try Understanding ASP.NET Validation Techniques[^] or ASP.NET Quickstart Tutorials : Validating Form Input Controls[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Many thanks again for your reply and the validation links which I have bookmarked and will return to.
With my three fields only - username, password, and confirm password - things are fine. No errors and the form looks pretty!
However, when I copy and paste the following into my source code (thank you for the email validation expression: it would have taken me an age to find that!):
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="Email" CssClass="col-md-2 control-label">Email</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="strEmail" TextMode="Email" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="strEmail"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The email field is required." />
<asp:RegularExpressionValidator runat="server" ControlToValidate="strEmail"
CssClass="text-danger" Display="Dynamic" ErrorMessage="Please enter a valid email address."
ValidationExpression="^.+@.+$" />
</div>
</div>
I get a 'Stack Empty' error.
I have ensured that the ID and ControltoValidate values are the same (namely, strEmail). There are, in fact two ControltoValidate attributes. I imagine they relate to 1) Ensure an email address is typed in, and 2) Ensure it passes the +@.+$ test. And the two error messages make sense.
So I am not sure where I am going wrong!
Thanks for your patience!
|
|
|
|
|
Member 8761667 wrote: There are, in fact two ControltoValidate attributes.
I assume you mean there's one attribute on each validator? One on the RequiredFieldValidator and one on the RegularExpressionValidator ? Each validator needs to know which control it needs to validate, so it has to have its own ControlToValidate attribute.
Member 8761667 wrote: I get a 'Stack Empty' error.
I've never heard of that one before. Can you post the full exception message and stack-track?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, here is the error when I preview the page in my browser:
Stack empty.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Stack empty.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Stack empty.]
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52
System.Collections.Generic.Stack`1.Pop() +6694385
Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.EndRendering(TextWriter writer, Object renderedObject) +152
System.Web.UI.RenderTraceListenerList.EndRendering(TextWriter writer, Object renderedObject) +58
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +142
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1386
Thanks!
|
|
|
|
|
|
OK, I have this - and only this - in the Web.config file now:
<appSettings>
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled"/>
</appSettings>
When I preview the page in the browser I get:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x8007000d
Config Error Configuration file '\\?\C:\Users\Steve\Documents\Visual Studio 2013\WebSites\WebSite5\web.config' does not contain a root <configuration> tag
Config File \\?\C:\Users\Steve\Documents\Visual Studio 2013\WebSites\WebSite5\web.config
Requested URL http:
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
Request Tracing Directory C:\Users\Steve\Documents\IISExpress\TraceLogFiles\
Config Source:
1: ="1.0"="utf-8"
2: <appSettings>
3: <add key="PageInspector:ServerCodeMappingSupport" value="Disabled"/>
More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.
|
|
|
|
|
You need to have <configuration> as the root element of the web.config file:
="1.0"
<configuration>
<appSettings>
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled"/>
</appSettings>
</configuration>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The error message I get now doesn't even seem related to my code. I get:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: 'DefaultAuthenticationTypes' is not declared. It may be inaccessible due to its protection level.
Source Error:
Line 10: ' This is required if your application allows users to login
Line 11: app.UseCookieAuthentication(New CookieAuthenticationOptions() With {
Line 12: .AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
Line 13: .LoginPath = New PathString("/Account/Login")})
Line 14: app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie)
Source File: C:\Users\Steve\Documents\Visual Studio 2013\WebSites\WebSite5\App_Code\Startup.Auth.vb Line: 12
There is no reference in my code to AuthenticationType or LoginPath
I have this in Web.config as per your good self:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled"/>
</appSettings>
</configuration>
And this in my aspx page:
<%@ Page Title="Register" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Register.aspx.vb" Inherits="Account_Register" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<h2><%: Title %>.</h2>
<p class="text-danger">
<asp:Literal runat="server" ID="ErrorMessage" />
</p>
<div class="form-horizontal">
<h4>Create a new account.</h4>
<hr />
<asp:ValidationSummary runat="server" CssClass="text-danger" />
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="UserName" CssClass="col-md-2 control-label">User name</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="UserName" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="UserName"
CssClass="text-danger" ErrorMessage="The user name field is required." />
</div>
</div>
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="Password" CssClass="col-md-2 control-label">Password</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="Password" TextMode="Password" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Password"
CssClass="text-danger" ErrorMessage="The password field is required." />
</div>
</div>
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="ConfirmPassword" CssClass="col-md-2 control-label">Confirm password</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The confirm password field is required." />
<asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The password and confirmation password do not match." />
</div>
</div>
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="Email" CssClass="col-md-2 control-label">Email</asp:Label>
<div class="col-md-10">
<asp:TextBox runat="server" ID="strEmail" TextMode="Email" CssClass="form-control" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="strEmail"
CssClass="text-danger" Display="Dynamic" ErrorMessage="The email field is required." />
<asp:RegularExpressionValidator runat="server" ControlToValidate="strEmail"
CssClass="text-danger" Display="Dynamic" ErrorMessage="Please enter a valid email address."
ValidationExpression="^.+@.+$" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<asp:Button runat="server" OnClick="CreateUser_Click" Text="Register" CssClass="btn btn-default" />
</div>
</div>
</div>
</asp:Content>
That's it, in its entirety.
|
|
|
|
|
There must have been some additional settings in your web.config file before you deleted them to add the new setting.
Do you have a backup copy of the file? If not, you'll need to create a new ASP.NET project and copy the web.config file over.
Either way, you need to add the new setting to the existing settings; don't delete the existing content of the file!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, that sounds sensible.
I'll keep this project but open a New Project, insert the form fields in the aspx file and your Web.config settings in the Web.config file and go from there!!
Thank you for all these hours of your time: I'm grateful.
Blue
|
|
|
|
|
I'm playing around with counting how many users are online.
So I added this to the Global.asax file
Sub Session_Start()
guestCount = Convert.ToInt32(Application("guestCount"))
Application("guestCount") = guestCount + 1
End Sub
Sub Session_End()
Application("guestCount") = guestCount - 1
Session.Clear()
End Sub
I'm trying to access Application data in a server control, but I can't figure out how to check the existence or access the value.
This is what I have, but I'm not even close to getting it right. I thought I could access the data using something like a session value, but not the case.
Dim m As HttpApplicationState = HttpApplicationState
If Not (Application("guestCount") Is Nothing) Then
lbl_OnlineUser_Count_Field.Text = Application("guestCount")
End If
|
|
|
|
|
I feel dumb here, it is just like a session value.
If Not (HttpContext.Current.Application("guestCount") Is Nothing) Then
lbl_OnlineUser_Count_Field.Text = HttpContext.Current.Application("guestCount")
End If
|
|
|
|
|
Don't forget to add ToString() at the end
|
|
|
|
|
Oh thanks for the reminder!
It doesn't work very well at the moment, session timeouts are to long. I need to rethink how it works.
|
|
|
|
|
Did someone break the .NET 3.5 version of MicrosoftAjax.js on Windows 8.1 update 1, or is it just my PC?
Handlers added via Sys.Application.add_init work fine on the server (Windows 2008 R2), but never fire on my new PC. (Tested in Firefox 29.1)
The only difference I can find is the MicrosoftAjax.js file:
Server:
FileVersion: 3.5.30729.5458
function Sys$_Application$initialize() {
if (arguments.length !== 0) throw Error.parameterCount();
if(!this._initialized && !this._initializing) {
this._initializing = true;
window.setTimeout(Function.createDelegate(this, this._doInitialize), 0);
}
}
Local:
FileVersion: 3.5.30729.7903
function Sys$_Application$initialize() {
if (arguments.length !== 0) throw Error.parameterCount();
if(!this._initialized && !this._initializing) {
this._initializing = true;
var check, er, app = this;
function init() { if (!app._initialized) app._doInitialize(); }
var onload = function() {
Sys.UI.DomEvent.removeHandler(window, "load", onload);
init();
}
Sys.UI.DomEvent.addHandler(window, "load", onload);
if (document.addEventListener) {
try {
document.addEventListener("DOMContentLoaded", check = function() {
document.removeEventListener("DOMContentLoaded", check, false);
init();
}, false);
}
catch (er) { }
}
else if (document.attachEvent) {
if ((window == window.top) && document.documentElement.doScroll) {
var timeout, el = document.createElement("div");
check = function() {
try {
el.doScroll("left");
}
catch (er) {
timeout = window.setTimeout(check, 0);
return;
}
el = null;
init();
}
check();
}
else {
document.attachEvent("onreadystatechange", check = function() {
if (document.readyState === "complete") {
document.detachEvent("onreadystatechange", check);
init();
}
});
}
}
}
}
Yes, I know WebForms is no longer "cool", and I should have rewritten everything in the latest bleeding-edge pre-alpha CTP version of whatever was the last framework to come out of Redmond, but some of us have work to do!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dears,
I have one problem that our system which is made by the web application ASP.net and the report made by crystal report (Visual Studio 2005) so I want printing the report without asking the printer name and the preview so can you help me to be printing as direct.
So i will be much appropriated if you send me a small sample to be print directly from web application.
Thanks
|
|
|
|
|
Are you aware of the fact that printing on the web is done on the client side? On the client's machine?
In a web page (on the client side) you may print the web page (as-is) using window.print method, or you can supply the user with a prepared file (like pdf) and open it to print. Even in the first scenario you can not ensure window.print will run automatically...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
hi
I have a datalist with som controls in it, one of them is check box,
i want have a compare with two item(click 2 checkboxes, for comparing two product in my websit) so when checked two of them and user push compareBtn my codes go to another page with 2 valu (productId)
how to do it
A Day Without Learning Is A Lost Day!
|
|
|
|