|
Hi experts,
I am not sure whether to post this on JavaScript forum or here. Please forgive me if I posted at the wrong forum.
I have a javascript that calculates the different between start time and end time.
The value of the difference is stored in a variable called hourDiff.
var hourDiff = endDate - startDate;
Below, I am passing some form variables from one page to another page called Reserve.aspx using asp.net.
Code is below:
<asp:HyperLink ID="siteId" style="color:#111" runat="server" navigateurl='<%# String.Format("Reserve.aspx?id={0}&groupsize={1}&facilityFees={2}&extrahour={3}&depoitAmt={4}&cancelAmt={5}&keydeptAmt={6}", Eval("siteId"), Eval("capacity"),Eval("RentalFeeAmount"),Eval("ExtraHourAmount"),Eval("DepositAmount"),Eval("CancellationAmount"),Eval("KeyDepositAmount")) %>' Text='Select' />
Is it possible to pass this javascript variable as part of the hyperlink?
If no, is there another way to do this?
Basically, assuming that acceptable hour difference is 2, anything above 2 incurs additional fees.
So, I wanted to pass that variable to Reserve.aspx page so I can substract 2 from whatever the total hourDiff is and if the difference is greater than 0 than add x amount of additional charges to the total hours greater than 2.
Your help is greatly appreciated.
|
|
|
|
|
|
Dear just do two simple steps:
1. First hourDiffvalue into a hidden field.
2. Then Pass the hidden field value to hyperlink as
<asp:HyperLink ID="siteId" style="color:#111" runat="server" navigateurl='<%# String.Format("Reserve.aspx?id="+<b>HiddenField1.Value</b>+"&groupsize={1}&facilityFees={2}&extrahour={3}&depoitAmt={4}&cancelAmt={5}&keydeptAmt={6}", Eval("siteId"), Eval("capacity"),Eval("RentalFeeAmount"),Eval("ExtraHourAmount"),Eval("DepositAmount"),Eval("CancellationAmount"),Eval("KeyDepositAmount")) %>' Text='Select' />
|
|
|
|
|
I used that starter project to create my first website. I'm done with the contollers and views, I made my HTML pages, and wanted to modify the register user program. So I made my textboxes, modified the AccountModel for it, and ran into a road block. The logic or the code in compiled is in a DLL, or I guess called a plugin or package.
This is what I wanted to modify, add some fields like Company Name and Email Address
F:\packages\Microsoft.AspNet.WebPages.WebData.3.2.3\lib\net45\WebMatrix.WebData.dll
WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
So this is a pre-fabricated dll from NuGet, in which the source code is kept safe for?
And I have to write my own gig in order to do this?
So my question is:
If I want to start writing my own stuff here for my MVC Project, I have to create a new project, and compile it as a DLL, and add a reference to it, or write something in the App_Code folder to experiment with?
Not quite sure how to precede here. I searched around and couldn't figure out the keywords of what to look for.
|
|
|
|
|
I just got schooled in Simple Membership and the WebMatrix DLL
When I saw how much code was in the DLL, I decided not to touch it.
So then I started thinking, I can't be the only one that wants to modify it, so I used keywords for modifying SimpleMembership.
It took a couple of tries, but now I got it, well at least the database was created. Now I need to test the Register part.
I used answer 2, the non destructive method.
http://stackoverflow.com/questions/12435252/how-to-create-custom-additional-fields-in-userprofile-in-mvc4[^]
|
|
|
|
|
Not sure if I did this right, but I had to get the Register working.
So I modified the ActionResult register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
try
{
WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
int userID = WebSecurity.GetUserId(model.UserName);
bool s = WebSecurityExtender.UpdateUserAndAccount(userID, model.Name, model.CompanyName, model.EmailAddress);
WebSecurity.Login(model.UserName, model.Password);
return RedirectToAction("Index", "Home");
}
catch (MembershipCreateUserException e)
{
ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
}
}
return View(model);
}
And wrote sort of an extender in App_Code
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace WebMatrix.WebData
{
public class WebSecurityExtender
{
public static bool UpdateUserAndAccount(int userID, string name, string companyName, string emailAddress)
{
bool success = false;
string connStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
string query =
"UPDATE " +
" UserProfile " +
"SET " +
" Name = @Name " +
" ,CompanyName = @CompanyName " +
" ,EmailAddress = @EmailAddress " +
" WHERE UserID = @UserID ";
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.Add(new SqlParameter("@UserID", userID));
cmd.Parameters.Add(new SqlParameter("@Name", name));
cmd.Parameters.Add(new SqlParameter("@CompanyName", companyName));
cmd.Parameters.Add(new SqlParameter("@EmailAddress", emailAddress));
try
{
conn.Open();
cmd.BeginExecuteNonQuery();
}
finally
{
conn.Close();
}
return success;
}
}
}
This is my first time working with MVC and C-Sharpe, and I know I could of done better in the database call, but I really had nothing to go on here. I need to add the catch as well.
|
|
|
|
|
I my webform asp.net project, I use web api controller to access the server data.
I use framework 4.5.
On localhost everything works, but when I publish to server I get 404 for http://www.mydomain.it/api/fileupload/UlpoadFileMat.
This is the code in file global.asax
<pre lang="xml">
protected void Application_Start(object sender, EventArgs e)
{
GlobalConfiguration.Configure(config =&amp;gt;
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: &amp;quot;DefaultApi&amp;quot;,
routeTemplate: &amp;quot;api/{controller}/{action}/{id}&amp;quot;,
defaults: new { id = RouteParameter.Optional }
);
});
}
On the server the framework 4.5 is installed.
In IIS, in application pool, I've set the correct framework version.
What is the problem?
What are the server requirements? What should I install?
Thanks
|
|
|
|
|
I have a ASP.Net 3.5 web application with SQL 2008 as the back-end. I used ADO.Net's enterprise library Data Helper classes (Entlib 4.1) to access the DB and its stored procedures.
I initially set the CONTEXT_INFO in a stored procedure and then in subsequent stored procedures, I use the value set in CONTEXT_INFO to filter the queries. It worked perfectly in this setup.
I then migrated to ASP.NET 4.5.1 framework with EntLib 6 (tried with 5 also). I am facing a fundamental issue in that the CONTEXT_INFO value is not being retained between 2 subsequent SP calls. I have not closed the connection between calling the SP's/subsequent calls. Therefore none of my SP's return values.
SP for setting CONTEXT_INFO
----------------------------
DECLARE @ContextInfo varbinary(128)
SELECT @ContextInfo = cast( @SomeIDPassed AS varbinary(128) )
SET CONTEXT_INFO @ContextInfo
Other SP using CONTEXT_INFO
---------------------------
(CONVERT(int, RTRIM(REPLACE(CONVERT(varchar(128), CONTEXT_INFO()),char(0), '')))))
Please provide your inputs
Thanks,
Anand
|
|
|
|
|
I'm trying to figure out how to create a link to download one of my windows apps.
I'm new at this, HTML5, CSS3, MVC and c# all at the same time.
So in my view, I wrote this. If the user is logged in, they can download the file, and vice versus. It seems to work fine, not sure if I did it the right way or not.
<h5>How to get Streakwave Reseller 2015 today</h5>
<p>
Simply register an account, so we can get an idea if folks are using it, and click on
Installation takes about 30 minutes, including the download of LocalDB, and the <br />
Currently the program is shareware, or free to use,
Current Version is 1.1.0.784
@{
if (User.Identity.Name == "")
{
<section id="login" style="text-align: left;">
@Html.Partial("_LoginPartial")
</section>
}
else {
<section>
@Html.ActionLink("Download Streakwave Reseller 2015", "StreakwaveReseller2015_DownloadApp", "Apps")
</section>
};
}
</p>
Now on this part, I'm not sure if I use the controller file, and change the view to code that starts the download. Or if I have to create or use the assigned model to do that. My knowledge learned says use the controller file. So if I use the controller file, then I don't need a view file then?, because there is no view.
public ActionResult StreakwaveReseller2015_DownloadApp()
{
return View();
}
Or am I completely off the tracks here on this one.
If I am on the right track, I not sure what to write in the controller action result, and point in the right direction would be of great service to me.
|
|
|
|
|
From my limited knowledge of MVC, I suspect you want to return a FileResult object by calling one of the File methods[^]:
public ActionResult StreakwaveReseller2015_DownloadApp()
{
return File("~/path/to/the/file.exe",
System.Net.Mime.MediaTypeNames.Application.Octet,
"TheDownloadFileName.exe");
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My knowledge is limited as well here.
I thinks its a FileResult, I wrote this in the last 15 minutes, and it worked, very close to yours. Not sure if it's right or not.
But that's pretty slick in design, A action link on a view, in which the controller action lets you run the a small amount of code to download a file instead of showing another web page.
I have so much to learn here, I like being able to jam out code fast. Not bad considering I'm a VB guy by heart.
Let's see what others say about it. Thanks Richard!
public FileResult StreakwaveReseller2015_DownloadApp()
{
string filePath = Server.MapPath("~/Downloads/Streakwave/streakwave_1.1.0.784.exe");
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, "streakwave_1.1.0.784.exe");
}
|
|
|
|
|
Just make sure your ~/Downloads/Streakwave/ folder is protected, so that nobody can download the file directly.
You can change the settings through IIS or appcmd [^], or add the following to the web.config file in that folder:
<configuration>
<system.webServer>
<handlers accessPolicy="None" />
</system.webServer>
</configuration>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The config turned off everything on me, server error 500.1 or something.
Should of used read, or something.
I just solved my redirect login, the IsLocalUrl, so I'll tackle that tomorrow morning.
You have to login or register to download the file.
[edit]
MVC does let you download the file in you type directly. Interesting. Maybe I should of put it in app_Data, since I'm reading the bytes.
|
|
|
|
|
The config file I posted should prevent you from downloading the file directly. I've used it on lots of sites without any problems.
If you're getting a 500 error when you add it, try accessing the site from the server to see the full details of the error.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK, will give that a try today.
|
|
|
|
|
Hi Every Body,
Can any one help!
How to create a new MVC Application using any CMS Template.
Thanks in advance.
|
|
|
|
|
What do you mean by "using any CMS template"?
|
|
|
|
|
In asp.net which cms is provide more security for developing website? customized cms or third party cms like dnn,wordpress,umbraco,etc.. ?.
|
|
|
|
|
What do you mean by "more security"? More security features or what?
|
|
|
|
|
Sir,dnn,wordpress are open source so any one can hack immediately into the project.but customized cms is more secure than third party cms??
|
|
|
|
|
RajeeshMenoth wrote: so any one can hack immediately into the project
Since when does "open source" mean "less secure"? Having access to the source code does not mean you're going to know where all the weaknesses are. There are plenty of other things you have to do to the server that have nothing to do with the application code to properly secure the server.
|
|
|
|
|
I want to add navigation method in my project,but i am not able to add all navigation method Please give me coding of all method.
|
|
|
|
|
Yeah, that's not going to happen. There are simply too many different ways of doing navigation. All you have to go is Google for "ASP.NET navigation" and you'll come up with all kinds of ideas and 3rd party controls to do this.
|
|
|
|
|
Hi... run time i'm getting error as "Uh-oh, something went wrong! Error Code: 500".
In web.config file, i specified custom error mode to "off": <customerrors mode="Off">
Then also i'm getting same error..
any help appreciated...!
Thank you
|
|
|
|
|
That is a custom error, designed by the developer (maybe you) to hide the actual error in the background.
The 500 tells the developer that there has have been some run-time error, such as some error that broke the code and threw this error. Try re-loading the website in your IIS to re-compile and start the website's settings from beginning. Then it would display the error.
(If you're using Visual Studio as your IDE)
Otherwise, a side-note can be to debug the website using Visual Studio. Add a breakpoint to your functions, and Visual Studio would help you in catching the errors.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|