i have a webform which has got required field validators. when the user doesnt enter values and clicks submit button it should not cause postback. i have set CausesValidation="True" on the submit button.hen the user clicks submit button without entering values, validation occurs( red * marks are shown) but the postback also occurs.
I have a problem whenever i run my code i get the following error ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.1.46-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ('b'), ('Manager'), ('c'), ('d'), ('e')' at line 1 my code works with connector/net but my host does not have it installed so i've had to change my code to odbc which they do have, i have found out the syntax is different and changed my code accordingly my code is as follows
I am using VS 2008.I am building a datatable of records to be inserted into a SQL Server 2005 table. The program loops through this table and builds a SqlParameter for each DataColumn in the datatable. The SqlParameters are used in the SQL Insert statement.
The field I am having a problem with is of type 'bit' in the database table and has no default value and cannot be nulls. The field is called 'Active' The meaning of this field in the application is Boolean i.e True or False. When inserting the record, I wish to default the field to "False".
When I define the columns in the datatable I am forced to use the following code to build the datatcolumn containing the boolean field i.e. dtcActive.DataType = GetType(Boolean) as there is no GetType(Bit)
Dim dtcActive As New DataColumn("Active") dtcActive.DataType = GetType(Boolean) dtcActive.Unique = False dtcActive.AllowDBNull = False dtcActive.DefaultValue = False dtProviderDayDetails.Columns.Add(dtcActive)
However, when I build the SqlParameter I am forced to use this:
If field.ColumnName = "Active" Then prm.SqlDbType = SqlDbType.Bit prm.Value = "False" End If
This is because there is no SqlDbType.Boolean. The problem I have is there is no value I have been able to give the SqlParameter that is accepted by the Insert statement. It complains that the boolean field cannot be null on Insert.
I'm developing an ASP.NET app with a MySQL backend, using the MySQL Connector Net 6.2.3. I have a DetailsView with an insert command that is throwing the error:MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?,?,?,?,?,?,?)' at line 1My code is:
[Code]....
If I hardcode values into the insert statement, it works fine. But when I put the ? placeholder in, it throws the error. Can anyone help me pinpoint the problem or offer a workaround solution?
I want to issue an INSERT command for an SQL Server table using DataAdapter without first issuing a SELECT command. Could anybody send me lines of code to handle this? Also how do i manage INSERT into selective table columns (I have 10 columns but i only want to update 2 of them)?
I am working with odbcCommand class, in one case I got error that QueryTimeout Expired. Even though this SP is taking only 3-4 secs in DB to execute these specific values, When I set the CommandTimeout=0, then it worked fine.
1)Is it necessary to always use this property while working with Command Class.
2)If it is not suggested to use, but still if I use it then how it will impact the performance.
Below is my code sample.
OdbcConnection conObj; OdbcCommand cmdObj; OdbcDataAdapter daObj = new OdbcDataAdapter(); public DataTable GetIFAContractNoteData(string RecipientIDIFACN, DateTime BatchDateIFACN, int TransmittalReportIDIFACN) { conObj = new OdbcConnection(GlobalVariables.strDsnName + ";" + GlobalVariables.strDsnDataBase + ";" + GlobalVariables.strDsnUserID + ";" + GlobalVariables.strDsnPassword);
I have a server control that needs to programmatically inject a JavaScript reference into the page. It is to reference Microsoft's Bing map control which requires &s=1 to be appended to the script URL for use over SSL. The problem is that the .NET Framework encodes the attributes and changes the & to an & (verified with Reflector). At some point after that the & is removed altogether.
Desired script tag: <script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"> </script> Attempt 1: var clientScriptManager = this.Page.ClientScript; if (!clientScriptManager.IsClientScriptIncludeRegistered(this.GetType(), "BingMapControl")) { clientScriptManager.RegisterClientScriptInclude( this.GetType(), "BingMapControl", "https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"); } Attempt 2: HtmlGenericControl include = new HtmlGenericControl("script"); include.Attributes.Add("type", "text/javascript"); include.Attributes.Add("src", "https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"); this.Page.Header.Controls.Add(include);
public abstract class Foo { public Injectable Prop {get;set;} }
i have an application that i want to enhance and simultaneously refactor for simplicity.
I have over 100 classes that call some same stuff (e.g Class Injectable) and i am thinking that this behaviour can be abstracted and set to a base class, and everybody will inherit from this base class so as to remove copy/paste code.
However, i want to avoid copy/paste code in the spring configuration file by defining an Injectable object and then define a child object foreach and every class that inherits from Foo.
I am looking for a way to set the abstract class's properties and then all child elements to automatically get them via configuration. I want to avoid to make the abstract class like this:
I had came acroos an open source a java applet. I wanted to know is there somehow I could create a script that could be distributed and the applet could be embedded in any website? I have been able to inject jquery and JS scripts into websites by placing a tag pointing to a Javascript file and placing it in the header of the page but I don't know how a java applet can be injected?
I would like to create a custom action filter attribute that adds a value in the HttpContext items that would be accessible during model binding.
I have tried to add it in the OnActionExecuting but it that seems the modelbinding is exectued before the filter. Maybe there's a method in the modelbinder that I could override that will be fired after the filter and use the value injected by my filter.
What I want to do, is to inject a validation context (the library I use for validation supports context, it is nvalid.net (www.nvalid.net) I would like to be able to place an attribute such as
[ValidationContext("Prevalidation")]
on my actionresult method, so that the validation that occurs in my custom model binder could know which context to use when doing the Validation. That's why I can't simply make a custom model binder.
I have a tricky problem and I'm not sure where in the view rendering process to attempt this. I am building a simple blog/CMS in MVC and I would like to inject a some html (preferably a partial view) into the page if the user is logged in as an admin (and therefore has edit privileges).
I obviously could add render partials to master pages etc. But in my system master pages/views are the "templates" of the CMS and therefore should not contain CMS specific <% %> markup. I would like to hook in to some part of the rendering process and inject the html myself.
how to do this in MVC? Where would be the best point, ViewPage, ViewEngine?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyPage.aspx.cs" Inherits="MyPage" %> <script type="text/javascript"> //<!-- I want to inject a JSON string here, which is generated per side-request --> function doStuffToMyData(){ // ..... } </script>
how I can inject a JSON string here? I got no problem generating the string, or parsing it in the browser..
It could be there's an easier way to do this? I basically want to manipulate the looks of the side, depending on changes to this data, so I figured it would be easiest to have the data as a JSON string.
I have a simple, but probably common problem on how to inject HTML inside an ASP.NET MVC master page. I have a google analytics tracking code that sits on my master page. The code looks like this:
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-1']); _gaq.push(['_trackPageview']); // need to inject ecommerce code here (function () { // google analytics code here })();
I'm using ecommerce tracking and I want to inject the "cart" information in side this HTML on the receipt page (and ONLY on this page). So I do something like this:
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-1']); _gaq.push(['_trackPageview']); <% if(ViewData["googleanalytics"]!=null) {%> <%= ViewData["googleanalytics"] %> <% } %> (function () { // google analytics code here })();
Then in the controller, I have code that looks like this:
[HttpGet] public ActionResult Receipt() { var receipt = // get receipt model // get google analytics javascript. This function pulls // the data from the receipt model ViewData["googleanalytics"] = GetAnalyticsInfo(receipt); return View(receipt); }
I currently work on an in-house 'CMS' that is fairly old. It has one 'content' field where the html of a CKEditor is saved and presented to each content page.
What I would like to do is be able to replace some special tags with the output of a control. So for example:
The content string would be
[Code]....
Then, when rendering the page, replace the '[%LatestNews(to=2010/01/01)%]' with the result of a user control. The user control may contain a asp:Repeater control or something that lists the required content.
Recently, I had prepared a java applet for my browser. I wanted to know is there somehow I could create a script that could be distributed and the applet could be embedded in any website?
I have an Html Form that I want to set focus to when the page loads. What I have done is coded the Site.Master to run a javascript function on page load. That js function retrieves a hardcoded form name from the DOM and, if found, sets focus to an input field in that form.
The httpmodule is used in my web application. I want to set the property in the httpmodule when my application starts and not have the overhead of setting it everytime the module is called.
The value for the application is read from my app settings in the web.config.
The httpmodule resides in a seperate dll to the web application.
So I want to inject/set the property from my web application on application start.
I've recently started working in ASP.NET and RDBMS.I'm making a test form where I can do basic add,update,delete operations.I'm using OracleDataClient to do the DB operations.I was able to populate a listbox using OracleDataAdapter.
Now after clicking on update button,I intend to Update in DB.I've Dataadapter with it's update property.But the update query is not happening.The examples I saw over net all have Select command before Update.Is it actually like that or am I missing some point.
How does Oracle DataClient work with Insert,Update,Delete Commands.
I have a profile object in session with profile information for the currently logged in user. I wand to be able to inject it into my business classes so I can do validation etc in them without having to pass it in the parameter list in every method.
I have tried something like this in my ninject module:
Profile profile = HttpContext.Current.Session["Profile"] as Profile; Bind<Profile>().ToConstant(profile).InTransientScope();
However it blows up with null reference when I do Kernel.Get() in my aspx. The BusinessObject takes a profile via the constructor. If I hard code the profile instead of using the HttpContext then everything seems to work. Not sure if ToConstant is the way to go, I am really looking for something that will get evaluated every time a new BusinessObject is created.
UPDATE
It seems that asking for injection to happen on a page level object inline is too soon for the session collection to be available. If I move in the Kernel.Get call to Page_Load it works just fine.