|
That is why, SPAs use a client-side framework, such as Knockout etc instead of server-side. You need to learn how to use, example, Knockout.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I want to pass the ACTIVITY_ID field (which is primary key) on an update statement where clause . I need help on how to do that. Here is Update Statement and parameters:
conn.ConnectionString = strConnection;
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "UPDATE BUYING_ACTIVITY SET CUSTOMER_SOURCE_CODE = :custsrc, CUSTOMER_NAME =:name, CUSTOMER_CITY = :city, CUSTOMER_STATE = :state WHERE _ACTIVITY_ID = ?";
cmd.Parameters.Add(new OracleParameter(?));
cmd.Parameters.Add(new OracleParameter("custsrc", custsrc));
cmd.Parameters.Add(new OracleParameter("name", name));
cmd.Parameters.Add(new OracleParameter("city", city));
cmd.Parameters.Add(new OracleParameter("state", state));
cmd.ExecuteNonQuery();
conn.Close();
What value do I use to set = to ACTIVITY_ID on the WHERE clause is what I'm asking.
|
|
|
|
|
That is a Database question, nothing to do with ASP.NET.
|
|
|
|
|
You pass the value in the same way as the other parameters:
cmd.CommandText = "UPDATE BUYING_ACTIVITY SET CUSTOMER_SOURCE_CODE = :custsrc, CUSTOMER_NAME =:name, CUSTOMER_CITY = :city, CUSTOMER_STATE = :state WHERE _ACTIVITY_ID = :activity_id";
cmd.Parameters.Add(new OracleParameter("activity_id", activity_id));
cmd.Parameters.Add(new OracleParameter("custsrc", custsrc));
cmd.Parameters.Add(new OracleParameter("name", name));
cmd.Parameters.Add(new OracleParameter("city", city));
cmd.Parameters.Add(new OracleParameter("state", state));
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi All,
I have an MVC application which when I run the application it goes to http://localhost:49626/login.aspx?ReturnUrl=%2fhome%2findex, I am not sure why it goes and searches for the Login.aspx url, I am new to MVC, any help is going to be very helpful, I even set as specific page as this: home/index, still it goes onto login.aspx page.
I am very poor with url, I have register routes as below:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Startup class as below
public class Startup
{
public void Configuration(IAppBuilder app)
{
}
}
I have area registration as below:
public class HelpPageAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "HelpPage";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"HelpPage_Default",
"Help/{action}/{apiId}",
new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });
HelpPageConfig.Register(GlobalConfiguration.Configuration);
}
}
Any help is going to be very helpful for me as I am very poor in understanding the route mapping and configuration of ASP.Net MVC applications, any help a code snippet, a link or even suggestion would be very helpful, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Sounds like you've got Forms Authentication configured, but pointing to a WebForms login page.
Have a look in web.config , under system.web/authentication , particularly the loginUrl attribute on the forms element.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i want to ask about the post by ashish chaudhary, in which we are suppose to fill the datagrid and then export it to excel file. I am using the same code, but i am getting the error in the given below line.
"string Path = "D:\\DataListWebsite\\myexcelfile_" + DateTime.Now.ToString() + "_" + DateTime.Now.Month.ToString() + ".xls";
All the code is as it is..... No issue . Please help....
|
|
|
|
|
Should the quote in front of string be there?
|
|
|
|
|
Why not ask ashish chaudhary (whoever he/she is)?
|
|
|
|
|
First of all, like Richard said: Ask this question under their post because do not know the context that you are working under. So we cannot help you.
Finally, if the problem is with saving only you need to understand that you cannot have special symbols in filenames (": " for instance). DataTime object will hold these, for the time values, which causes the problem. That can be one of the problems here.
c# - How to remove illegal characters from path and filenames? - Stack Overflow[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
how to populate textboxes on dropdown selection using .net mvc sqlserver 2013 without entitydata.
|
|
|
|
|
By writing a lot of code. Where are you stuck? I'm sure there are examples online you could follow. Ask Google, she knows everything.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I want to show required validator when Contract is selected on this toggle.
<label for="exampleNASAControlNumber">Is this a Contract or Solicitation?:</label>
<label class="switch2">
<input class="switch-input2" type="checkbox" id="contractselection" name="contractselection" runat="server"/>
</label>
The validation should work for this only when contract is selected:
<label for="exampleStartDate" style="position:relative; right:17px;">Contract Start Period:<span style="color:red">*</span>:</label>
<div class="bootstrap-iso">
<div class="row">
<div class=" zero-padding-left">
<div class="input-group">
<div class="input-group-addon">
</div>
<input class="form-control" id="contractstartdate" name="contractstartdate" runat="server" placeholder="MM/DD/YYYY" type="text" style="width:240px;"/>
</div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" ForeColor="Red" runat="server" ControlToValidate ="contractstartdate" ErrorMessage="Please select a Contract Start Period">
</asp:RequiredFieldValidator>
and disabled for this validator:
<label for="exampleStartDate" style="position:relative; right:15px;">Solicitation Start Period:<span style="color:red">*</span>:</label>
<%----%>
<div class="bootstrap-iso">
<div class="input-group" style="position:relative; right:15px; width:296px;">
<div class="input-group-addon">
</div>
<input class="form-control" id="solicitationstartdate" name="solicitationstartdate" runat="server" placeholder="MM/DD/YYYY" type="text"/>
</div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" ForeColor="Red" runat="server" ControlToValidate ="solicitationstartdate" ErrorMessage="Please select a Solicitation Start Period">
</asp:RequiredFieldValidator>
The reverse of this when Solicitation is selected, the Contract Start Date validator should be disable and the Solicitation Start Date validator is enabled.
How do I do this?
|
|
|
|
|
I did it using manual validation and jQuery.Validator.js. for MVC
I never used the validator for WebForms.
But I would remove your validators and go manual.
I wrote a jquery script called load_cc_validator and called it when I toggled the form module in jquery.
So I wrote the HTML in Razor and manually assigned the values
<h4>Card information</h4>
<div class="form-group">
@Html.Label("Edit_CC_FirstName", "First name on card", new { @class = "control-label" })
<div class="input-group">
@Html.TextBox("Edit_CC_FirstName", "", new { @class = "form-control", data_val = "true", data_val_required = "Card first name required", placeholder = "First name on card" })
@Html.ValidationMessage("Edit_CC_FirstName", new { @class = "field-validation-valid", data_valmsg_replace = "true" })
</div>
</div>
<div class="cxo-paymentForms-creditCard-submit right">
@Html.Hidden("Edit_CC_PaymentID")
@Html.Hidden("Edit_CC_Brand")
<button class="btn btn-default btn-lg mobile" type="button" onclick="return editPayment_cancel()">Cancel</button>
<button class="btn checkout pull-right mobile" type="button" onclick="return submit_eCC()">Save</button>
</div>
submit_eCC is just a $ajax call to the controller to update the database, and has nothing to do with validation.
editPayment_cancel just clears the form and hides the form module.
Since I'm using $ajax, I set the Submit Form Handler to false to not submit a post back of the form.
And then wrote the script and called it. This example reflects the whole module, and would take too much time to condense
function load_eCC_validate() {
var $cC_form = $("#Edit_CreditCard"),
$cC_location = $("#Edit_CC_LocationName"),
$cC_fName = $("#Edit_CC_FirstName"),
$cC_lName = $("#Edit_CC_LastName"),
$cC_code = $("#Edit_CC_Code"),
$cC_phone = $("#Edit_CC_Phone");
$bA_streetAddress1 = $("#Edit_CC_StreetAddress1"),
$bA_city = $("#Edit_CC_City"),
$bA_stateCode = $("#Edit_CC_StateCode"),
$bA_postalCode = $("#Edit_CC_PostalCode"),
$bA_countryCode = $("#Edit_CC_CountryCode");
$cC_form.validate({<br />
errorClass: 'form-control input-validation-error',
validClass: 'form-control',
errorElement: 'span',
success: "valid",
rules: {
"Edit_CC_LocationName": {
required: true
},
"Edit_CC_FirstName": {
required: true
},
"Edit_CC_LastName": {
required: true
},
"Edit_CC_ExpMonth": {
required: true,
valueNotEquals: ""
},
"Edit_CC_ExpYear": {
required: true,
valueNotEquals: ""
},
"#Edit_CC_Code": {
required: true
},
"Edit_CC_Phone": {
required: true,
phoneUS: true
},
"Edit_CC_StreetAddress1": {
required: true
},
"Edit_CC_City": {
required: true
},
"Edit_CC_StateCode": {
required: true
},
"Edit_CC_PostalCode": {
required: true,
zipcodeUS: true
},
"Edit_CC_CountryCode": {
required: true
}
},
messages: {
"Edit_CC_LocationName": "Unique name is required",
"Edit_CC_FirstName": "Card first name required",
"Edit_CC_LastName": "Card last name required",
"Edit_CC_Code": "Card Security code required",
"Edit_CC_ExpMonth": "Card exp month required",
"Edit_CC_ExpYear": "Card exp year required",
"Edit_CC_Phone": "Phone number required",
"Edit_CC_StreetAddress1": "Billing street address required",
"Edit_CC_City": "Billing city required",
"Edit_CC_StateCode": "Please select your state",
"Edit_CC_PostalCode": "Postal/zip code required",
"Edit_CC_CountryCode": "Please select your country"
},
submitHandler: function (form) {
return false;<br />
},
invalidHandler: function (event, validator) {
var errors = validator.numberOfInvalids();<br />
},
errorPlacement: function (error, element) {
$(element).parent().next('span').html(error);
}
});
}
This works exactly like assigning required to the model, only I didn't assign required to the model.
Hope this makes sense to you, can't really explain it in more detail. But the HTML I posted is exactly what is needed to make it work.
Note, you may be able to disable validation using jquery by changing one of the attr in the validator. You have to look at the HTML that is generated to see which attr to change in the elements.
21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.
|
|
|
|
|
Perhaps Specifying Validation Groups may be what you need?
[^]
_______________________________________________________________
Ah don't lean on me man, cause you can't afford the ticket
|
|
|
|
|
ValidationGroup won't work. I only have one button on my form.
|
|
|
|
|
|
Is it possible to call a javascript function in a cshtml, in the @{} section, and the javascript function is defined in the script section of the cshtml.
Thanks
|
|
|
|
|
No, your cshtml is compiled and executed as .net code on the server, the result is that it generates html, that html is then sent to the client browser to be executed and the client browser can interpret and execute javascript. So you can't run javascript in your views as the javascript doesn't yet technically exist.
|
|
|
|
|
I have a list passed on to the view from the controller through a viewbag. so if the viewbag has the list, then execute a javascript function that is defined in the script section of the page. what is the other option?
|
|
|
|
|
<script type="text/javascript">
function myFunc() {
alert('Hello');
}
</script>
@if (ViewBag.MyList != null)
{
<script>myFunc();</script>
}
Note the order is important, js is interpreted in order so you can't call functions that have not yet been defined.
|
|
|
|
|
Hi,
I am trying to run npm install, I'm not sure what's it, all I doing is following an article to make my application workable with Angular 2.0, but its never stopping giving me errors. I don't know why is so tough to install it.
I have created package.json file, copied the following script init. ABCSolution is my solution name and ABCWebApp is my asp.net mvc application name, I don't know which one should I use for the name there, I putting the Solution Name
{
"version": "1.0.0",
"name": "ABCSolution",
"author": "Abdul Aleem",
"description": "This is for Calpers834",
"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.6",
"@angular/core": "2.0.0-rc.6",
"@angular/forms": "2.0.0-rc.6",
"@angular/http": "2.0.0-rc.6",
"@angular/platform-browser": "2.0.0-rc.6",
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
"@angular/router": "3.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.6",
"@types/lodash": "^4.14.42",
"core-js": "^2.4.1",
"moment": "^2.14.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "^0.19.37",
"typings": "^1.3.2",
"zone.js": "^0.6.12"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-less": "^3.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "^2.13.6",
"gulp-uglify": "^2.0.0",
"typescript": "^1.8.10"
},
"scripts": {
"postinstall": "typings install dt~core-js --global"
}
}
I have created typings.json file and placed the following script there
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160602141332",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160621231320"
}
}
I placed them in the Project folder first and ran the npm install from that same folder it gave me errors, then I placed these files in the Solution files, then ran the npm install, never leaving the errors.
I am frustrated and tired, I am not understanding what are those dependencies are what are those versions in them.
Can anybody please help me in this aspect, what went wrong, I really need this help a suggestion, a link or even a code snippet helps me greatly. What's this npm install why is it making my life so tired, I don't know.
And the error that I getting is as below:
npm ERR! peerinvalid The package @angular/common does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/forms@2.0.0-rc.6 wants @angular/common@^2.0.0-rc.6
npm ERR! peerinvalid Peer @angular/platform-browser@2.0.0-rc.6 wants @angular/common@^2.0.0-rc.6
npm ERR! peerinvalid Peer @angular/platform-browser-dynamic@2.0.0-rc.6 wants @angular/common@^2.0.0-rc.6
npm ERR! peerinvalid Peer @angular/router@3.0.0-rc.2 wants @angular/common@^2.0.0-rc.6
And if I am running "npm run typings install" in either the Project folder or Solution folder, then its giving me the following error:
npm ERR! missing script: typings
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <a href="https://github.com/npm/npm/issues">https:
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\aaleem01\Desktop\Calpers834\npm-debug.log
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 7-Dec-16 17:19pm.
|
|
|
|
|
Hi,
I created a mvc web project with scaffolding that displays well in the Index page. When I edit, I do not want any of the fields in the edit page to edit. Instead, I added a textbox whose value I calculate and save the rest of the fields to the database. I cannot get this to work, as the model in the HttpPost is null. Please help.
Thanks
|
|
|
|
|
Have you looked into any tutorials about doing CRUD in ASP.NET MVC? You should be able get more references in the web. The idea is to send back the model to your action method if your action requires the model on POST request. I would really recommend you to read the basics on how MVC arch works before jumping into the limbo.
Here's an article that may help you understand the basic of ASP.NET MVC: ASP.NET MVC 5: Building Your First Web Application - Part 1[^]
|
|
|
|
|
There's a problem somewhere in your secret code. You should fix that.
If you want someone else to help you fix it, then you'll need to share the relevant parts of your code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|