|
The problem is I can't use these attributes (type = "number", pattern = "[0-9]*", inputmode = "numeric"), because they need to change depending upon the selection or value of the selected value of the dropdown list.
But I could able to find the reason why its not working, because the textbox is in a partial view and as I am loading the partial view multiple times those functions are getting loaded multiple times, even if I use within document.ready, still it would be added multiple times. As I am opening the partial view as in the below Kendo grid popup , is there any way to clean this up once I close the popup or finish my task?
Page: Lookup2
<div id="datalist">
@(Html.Kendo().Grid<DHCS.BH.Provider.Models.LookupTable>()
.Name("LookupGrid")
.EnableCustomBinding(true)
.AutoBind(true)
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden();
columns.Bound(p => p.Code).Width(200);
columns.Bound(p => p.Description).Width(290);
columns.Bound(p => p.CreatedDate).ClientTemplate("#=DateFormat(CreatedDate)#").Width(130);
columns.Bound(p => p.CreatedBy).Width(150);
columns.Bound(p => p.ModifiedDate).ClientTemplate("#=DateFormat(ModifiedDate)#").Width(140); ;
columns.Bound(p => p.ModifiedBy).Width(150);
columns.Bound(p => p.IsValid).Width(100).Hidden();
////columns.Command(command => { command.Custom("View").Click("ViewLookupTableValues").HtmlAttributes(new { @class = "k-primary" }); }).Width(100);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
columns.Bound(p => p.LookupTableId).Hidden();
columns.Bound(p => p.ForeignKeyId).Hidden();
})
.ToolBar(toolbar =>
{
toolbar.Create().Text("Add New");//.HtmlAttributes(new { @class = "k-button" });
})//.HtmlAttributes(new { @class = "btn btn-primary" })
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("_EditLookupCode"))
.Pageable()
.Sortable()
.Scrollable()
.Resizable(resize => resize.Columns(true))
.Filterable(x => x.Extra(false).Operators(O => O.ForString(str => str.Clear().StartsWith("Starts With"))))
.HtmlAttributes(new { style = "height:550px;" })
<pre>
.Events(events => events.Edit("LookupPopUpTitle"))
.DataSource(ds => ds
.Ajax()
.PageSize(10)
.Model(model => { model.Id(p => p.Id); })
.Read(read => read.Action("GetLookupValues", "Admin").Data("GetLookupTableId"))
.Create(update => update.Action("AddLookupRecord", "Admin").Data("GetLookupTableId")).Events(e => e.Sync("GetLookupTableValue1"))
//.Create(c => c.)
.Update(update => update.Action("UpdateLookupRecord", "Admin"))//.Data("GetLookupTableId"))
.Destroy(update => update.Action("DeleteLookupRecordById", "Admin"))
)
)
Even this grid is also within Partial View and I am loading it by using javascript funtion as below:
Page name: lookup 1
var url = '../Admin/GetLookupTableCode';
$("#divLookupTable").load(url, { LookupTableId: $("#drpLookup").data("kendoDropDownList").value() });
seems that I need to clean these partial views once I am done with them, as the problem is happening in the Add New call of the Page: Lookup 2, I would need to clean it up it seems, (how did I come to this conclusion, because first time it worked properly then second time onward it started giving me problems), any help would be very very helpful my friend, I spent lot of time on it, thanks for understanding my friend.
or in simple, is there any way I can remove the document.ready that has been loaded and reload it again with the partial view load, because the if condition and function calls are not working directly if I am writing under script task like
if (x==y)
alert("Hi");
But works only once if I write the following within partial view cshtml
document.ready()(function({
if (x==y)
alert("Hi");
});
But this doesn't work, more than once maybe because it can not work if document.ready is loaded multiple times.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
-- modified 18-Jul-18 21:45pm.
|
|
|
|
|
I'm sort of confused now on what your trying to create. remember I'm not there with ya and can't see what your doing.
Document Ready is a signal indicating that the Dom is loaded, so you can execute client script automatically. Don't use it.
And write a new external file, don't write it on the view page.
I would imagine that your Document Ready would be empty, and when the dropdown changes value, then you call a independent JQuery Ajax function to load the partial view by calling a controller action and returning the HTML generated by the server.
You can wrap the partial view HTML in a wrapper with a known ID, so you can call $("#KnownID").empty() to dump the partial view and $("#KnownID").html(data.partialview); to load the partial view.
javascript - Render Partial View Using jQuery in ASP.NET MVC - Stack Overflow
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Yeah I can understand my friend, you are confused, and yes you are not with me to see and help directly, even doing this much is really really great - I think you live in LA, CA right? If you are travelling to Sacramento, CA, please please let me know I want to personally see you, meet you and thank you, if you don't mind give you a treat.
Because even helping this much to a person who you speak just online is great - you must be a great human.
And your imagination is right, there are two partial views I am loading, 1 I am loading with load method:
var url = '../Admin/GetLookupTableCode';
$("#divLookupTable").load(url, { LookupTableId: $("#drpLookup").data("kendoDropDownList").value() });
the other one I am loading with with Kendo popup:
.ToolBar(toolbar =>
{
toolbar.Create().Text("Add New");//.HtmlAttributes(new { @class = "k-button" });
})//.HtmlAttributes(new { @class = "btn btn-primary" })
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("_EditLookupCode"))
Somehow I need to clean these two Partial Views once I am done, , can you please let me know the syntax for how to wrap partial view within some known id and empty partial view after I am done or finished with it?
The first Popup that's being loaded with load method on the div "divLookupTable" just calls url with action method, loads within the same page, that contains a Kendo grid, which when clicked on Add New or Edit on a row, opens up partial view _EditLookupCode as a popup.
But if I have written the document.ready only in the main page and tried to retrieve the TextBox, that is placed in the Popup (of Partial View _EditLookupCode), I am not able to retrieve, if I kept my document.ready in the _EditLookupCode partial view itself, its giving me error after second run, but if I write any if else conditions withing this _EditLookupCode.cshtml partial view within script tasks, still its not executing.
Is there anyway I can retrieve the elements that are there on the _EditLookupCode.cshtml, note that this is the second partial view which opens up from click of a button on another partial view.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
I haven't been up in Northern California in a long time. I stopped there for gas on the way on from Seattle about 10 years ago.
I'd be glad to meet you!
I'm been following this on the thought that it's a single page application with no http postbacks.
just pure manipulation of the DOM using client script. I suspect the postbacks are messing you up and confusing me.
I can't write anything, and I think you have a flawed design in general and need to step back and rethink it.
I beginning to think that your trying to postback the Kendo Grid, or a textbox value depending on the dropdown selection.
You should be able to have both objects available, and just show and hide them. Then on the postback, check the dropdown value in the controller or page postback event, and use a switch to execute updating the selected section.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Thanks my friend, sure we will try to meet for a lunch or something when you are travelling here or when I am travelling in Orange County.
It seems there is something problem in it, I am very basic in jQuery and client script.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
hi Buddy,
I could able to do it by writing a function in the main page and calling that function multiple times in the popup whenever it loads, but another thing remaining is just putting numerical and text restrictions on the page depending upon the drop down selection.
Yes you were right I had flaw that I was trying to create function in the popup as it loads multiple times, we can't have function definition multiple times hence it was throwing error.
thanks a lot buddy.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
CODE:
part 1:
#region Save to Database
using (MyDatabaseEntities dc = new MyDatabaseEntities())
{
dc.Users.Add(user);
dc.SaveChanges();
SendVerificationLinkEmail(user.EmailID, user.ActivationCode.ToString());
message = "Registration successfully done. Account activation link " +
" has been sent to your email id:" + user.EmailID;
Status = true;
}
#endregion
part 2:
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromEmail.Address, fromEmailPassword)
};
using (var message = new MailMessage(fromEmail, toEmail)
{
Subject = subject,
Body = body,
IsBodyHtml = true
})
smtp.Send(message);
}
ERROR:
System.Net.Mail.SmtpException HResult=0x80131500 Message=The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at Source=RegistrationAndLogin StackTrace: at RegistrationAndLogin.Controllers.UserController.SendVerificationLinkEmail(String emailID, String activationCode, String emailFor) in D:\Jobshop\RegistrationAndLogin\RegistrationAndLogin\Controllers\UserController.cs:line 224 at RegistrationAndLogin.Controllers.UserController.Registration(User user) in D:\Jobshop\RegistrationAndLogin\RegistrationAndLogin\Controllers\UserController.cs:line 59 at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__11_0() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()
|
|
|
|
|
This is a very frequently asked question. Google "c# send email gmail" and you'll find lots of articles that discuss what you need to do to send email through gmail (they're not all code-related). However if you want my advice, don't;
Things you shouldn't spend time doing | The ASP.NET Forums[^]
|
|
|
|
|
You have to go to your gmail setup, and turn off secure authentication for that account.
Or write a more sophisticated function that includes a certificate for enhanced security.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
In my project while conversion of html to pdf using jspdf, Default download button is not working in chrome...Below is my code
var pdf = new jsPDF('p', 'pt', 'a4');
html2pdf(element, pdf, function (pdf) {
var string = pdf.output('datauristring');
var iframe = ""
var x = window.open();
x.document.open();
x.document.write(iframe);
x.document.close();
}
|
|
|
|
|
- This is nothing to do with ASP.NET;
- Either your code is incomplete, or you're not writing anything to the document;
- "Not working" is not enough information for anyone to help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well I started doing some optimization such as image compression and cache headers, and stumbled upon the fact that I just can't drop these files into the root of wwwroot and expect them to serve. I get the 404 error and redirect to my 404 page.
I ran across one article that says I need middleware for the favicon.
I'm not sure about the site map and robots.txt.
I keep searching but perhaps I'm just not asking the right question, can't find anything.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I got it now.
I used the Startup.cs, UseStaticFiles and polished it more for Favicon.ico and Google Verification, ServeUnknownFileTypes
Then added a Package and controller for Sitemap, and wrote a controller action for Robots.txt.
I added this, not sure if I need it, most likely not.
app.UseFileServer(new FileServerOptions() {
EnableDefaultFiles = false
});
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
My code is working fine for retrieval of 2 records from database after that its not working, no error.
Please help
rotected void btn_nxt_Click(object sender, EventArgs e)
{
i++;
s = er.scalarReturn("select min(q_id) from questions where q_id="+i);
if (s.Equals(""))
{
MessageBox.Show("Quize Over");
btn_nxt.Enabled = false;
}
else
{
i = Convert.ToInt32(s);
lb_qs.Text = er.scalarReturn("select q_title from questions where q_id=" + i);
lb_op1.Text = er.scalarReturn("select optiona from questions where q_id=" + i);
lb_op2.Text = er.scalarReturn("select optionb from questions where q_id=" + i);
lb_op3.Text = er.scalarReturn("select optionc from questions where q_id=" + i);
lb_op4.Text = er.scalarReturn("select optiond from questions where q_id=" + i);
}
}
|
|
|
|
|
First check that i is set to the correct id value you expect.
Second why not get the entire record in the first query and test if the object is null.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
MessageBox.Show will not work in an ASP.NET application. It might appear to work when you're debugging in Visual Studio; but that's only because the server and client are the same computer in that scenario. As soon as you deploy your code to a real server, it will break.
In the best-case scenario, you'll get an exception telling you that you can't display a messagebox from a non-interactive application. In the worst-case, the message will appear on the server, where nobody will ever see it, and your code will hang waiting for a response.
Sehal wrote: er.scalarReturn("select q_title from questions where q_id=" + i)
Whilst you're OK in this specific case (since the parameter is an integer), that code suggests that you've created a library which will force you to write code which is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
Sehal wrote: i++;
It looks like you're storing the current question number in a field on your page. Field values are not persisted between requests. You need to review the ASP.NET Page Lifecycle[^], and understand what's going on "behind the scenes".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well I was going to post a question on Reactjs and why it converted my model class to lowercase which crashed the page. Talk about a head scratchier, trying to figure out if my packages are not setup right, an error in my JSX file, or Bable.
<script>ReactDOM.hydrate(React.createElement(CommentBox, {"initialData":[{"id":1,"author":"Daniel Lo Nigro","text":"Hello ReactJS.NET World!"},{"id":2,"author":"Pete Hunt","text":"This is one comment"},{"id":3,"author":"Jordan Walke","text":"This is *another* comment"}],"url":"/comments","submitUrl":"/comments/new","pollInterval":2000}), document.getElementById("react_0HLF3D2L0PCGB"));
But I figured it out
<script>ReactDOM.hydrate(React.createElement(CommentBox, {"initialData":[{"Id":1,"Author":"Daniel Lo Nigro","Text":"Hello ReactJS.NET World!"},{"Id":2,"Author":"Pete Hunt","Text":"This is one comment"},{"Id":3,"Author":"Jordan Walke","Text":"This is *another* comment"}],"url":"/comments","submitUrl":"/comments/new","pollInterval":2000}), document.getElementById("react_0HLF3DH1L6U8N"));
</script>
Just had to change the NewtonSoft ContractResolver From CamelCase to DefaultContractResolver in in Startup.cs.
At any rate, I have just completed porting my app over, and it was really hard to learn all of these new concepts, while expanding on subjects I never bothered to look deeper into like HttpContext, Session and Cookie.
But what I ended up with is a very clean project with no clutter that is coded without evil bad habits.
I dumped some of the Razor elements for just tags and asp-....., which I might go farther with. Not sure if this is the death or Razor for me, or if I still need to use it.
I'm very happy with .Net Core 2.1 and I dig it. Seems really fast. Now I need to figure out what middleware is, and learn more about the details. Hopefully I server this up on my production web server.
I feel good about this!
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
How to use angular along with ASP.NET mvc project?
Aren't Angular and ASP.NET MVC mutually exclusive?
I mean angular is totally different than asp.net mvc,
here(asp.net) code executes on server and in another(angular) js code executes on client side.
asp.net view and angular view are totally different
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
There's an existing template in visual studio 2017 in .net core that use angular. I suggest you can see that project on how it works as a starting point.
Quote: asp.net view and angular view are totally different
An overview, asp.net view runs on server side and will return html to browser then AngularJS will then inspect the generated html (from server/asp.net) and executes to render and set the behavior accordingly.
[Signature space for sale]
|
|
|
|
|
Nitin Sawant wrote: I mean angular is totally different than asp.net mvc,
here(asp.net) code executes on server and in another(angular) js code executes on client side.
asp.net view and angular view are totally different
True.
Nitin Sawant wrote: How to use angular along with ASP.NET mvc project?
Angular is somewhat a client-side MVC. You can probably mix Angular and ASP.NET MVC but it's not ideal. You could however use ASP.NET Core / ASP.NET Web API with Angular to communicate with your data from the server and if you are really trying to build a SPA application.
modified 5-Jul-18 21:08pm.
|
|
|
|
|
You can probably mix Angular and ASP.NET MVC but its not ideal.
I wonder what is ideal to use with Angular I mean for authentication & db connectivity etc.
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
Quote: I wonder what is ideal to use with Angular I mean for authentication & db connectivity etc.
ASP.NET Core/ Web API as your back-end is the way to go.
|
|
|
|
|
I've been pondering the notion of mixing Angular with .Net MVC as well for about 3 weeks now.
Noticed how I wrote Angular and not AngularJS? AngularJS was the first version, then they changed the name to just Angular.
I just added Angular 5 to my .Net Core 2.1 project, and will write some Angular stuff next week. So I'm moving forward with it and decided to adopt it.
Why?
I questioned why so many software recruiters are looking for the Senior .Net Core 2 and Angular guy, and thought why? There both MVC except one is client and one is server. So I started searching the interwebs for the answer and this is what I found.
Weather.com
At first, I found weather.com, that uses Angular to display the weather for your city for that day. A single page app in which you can move to the next day, or a week, 10 day forecast, and the home page "Wall" of weather related topics. So I get it.
TV Guide
The I went to TV Guide, and saw similiar technology being used for TV Listings. You can hit next and get the listings for the next hour. Makes sense to me here as well.
Navigation
After that I realized that it could be used for menu's and navigation as well. Being able to take a Bootstrap dropdown menu and use Angular to populate departments, categories instead of the menu being static. Or create flyouts ads, and grab an ad using Angular and then animate it.
My thoughts
So MVC has the controller and Models, then you create a limited view, and finish it off with Angular. When I look at .Net Core 2.1, I can see how you can build a limited version of core with a couple View pages and serve up Angular or ReactJS pages instead. I'm looking at the Angular Demo now, and that would be too hard core for me to start with. I choose to use NPM and distribute it with Gulp and bundle it, and will try building another Angular page within a View.
Summary
Well that's as far as I have gotten on the subject. But once again it's another move towards shifting server CPU loads and bandwidth back to the client and use their CPU power and electricity to generate a page. Servers can just send Json formatted data. I'll find out in time if it's worth it or not, plus I have zero debate points to argue in favor of it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
jkirkerx wrote: notion of mixing Angular with .Net MVC
You probably can mix Angular and ASP.NET MVC, but if you are aiming for SPA, I would suggest to just stick to Angular as your front-end and use ASP.NET Web API /ASP.NET Core Web API as your back-end. Keep in mind that ASP.NET MVC is also front-end but generates pages from the server.
|
|
|
|
|
I'll get to that next week to see what you mean, and if my project build is correct.
But thanks for the heads up on that.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|