|
I created a new project, and put my stuff back in it to retain the design
Then I ran the NuGet, and updated all my packages
Figured out that I can't or don't know how to add a folder inside home view for /home/Apps
So I just added a new controller called Apps and a view /View/Apps for now.
The right Click works now add Controller, add view
And I have MVC version 5 now.
This is way different than web forms, but I can see the payoff in the future.
|
|
|
|
|
Hello, since you've not provided any code and/or any other background I am unable to guide you any further. Anyways, that link you provided is not applicable to my IIS and thus I am unable to examine the problem.
Anyhow, the problem is that beginners do get into this problem. I have an article[^], that you would find helpfull to you and you would find it easy to understand the ASP.NET MVC pattern, by using that example.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Well thanks for the offer for help. Really wasn't any code to post, because I didn't know what to post.
This is frustrating learning this, on top of CSS 3 and HTML5, but so far so good.
Here's what I have now. Keep in mind that I just started learning MVC this Monday, 3 days ago. So I thought why not update my website first, and see how it goes.
http://www.redcopper.net[^]
|
|
|
|
|
You should've posted the methods in which you're creating the application, the controllers and their representative views etc.
Anyhow, it doesn't take much time to understand the ASP.NET MVC pattern, you just need to first make yourself clear with the concept of the MVC pattern, and the code patterns in ASP.NET. Rest of the things would be learnt on the way. Mostly, 404 errors are generated when there is no file in your website to display in your browser, or none of the routings meet the URL.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
There must be a bond in which the controller is recognized, so it picks up the view.
Plus I found out the views must be in the folder that the controller makes.
Was sort of looking for the file in which this bond is made, unless it's a automatic search in the whole view folder structure.
|
|
|
|
|
Did you even read that article[^] that I tried to ask you to read? That has atleast the basic concepts of the ASP.NET MVC framework. You would get how and which pages are used in the MVC as the Views, how Controller acts and all other underlying things.
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 did read your article.
I understand how it works
I had trouble with Visual Studio 2013, in which I wasn't able to get the same right clicks and menu choices as show in your examples.
I made the mistake of opening the project as a website, and not a project, so VS2013 didn't know it was a MVC App.
Now I open it as a project, and all is fine.
|
|
|
|
|
Hello Everyone,
Please i would appreciate any urgent answer/help on the above subject. Actually, am about to start working on a project that involves developing a website where registered employees (on a remote desktop application) can come and view their basic information.
I understand i need to make some API calls that would fetch the data from the remote desktop database and render it on html for the users.
Please can anyone provide me with useful tip/tutorial/guide/reference on how to start?
Thanks in advance.
IsoftTech
modified 11-Feb-15 10:16am.
|
|
|
|
|
There are multiple ways of doing this, but the first thing as I have already said in almost all of my answers to such question is the "connection string". You're required to have the connection string, which is composed of the server's address (or atleast the name to which you would connect it to), the name of the database, and the required credentials for connection.
Once that has been taken care of you can then use the SQL commands to perform different actions on the database, which would include extraction, insertion or updation etc. Please go through this article[^] of mine to get a few more understanding of the concept.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thanks Afzaal for your response. I went through your article and observed that it was about connecting to a local database as oppose connecting to remote database via a Web API.
IsoftTech
|
|
|
|
|
Sorry for any problem you had to face, but the article had a section the connection string section. That depicts the usage of a connection string to connection to remove databases. If you go to the connectionstrings website then you would see how to connect to a remote database, remaining code is similar, the only thing to worry about is the connection string. Did you try that out?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Server Error in '/' Application.
Operation must use an updateable query.
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.Data.OleDb.OleDbException: Operation must use an updateable query.
Source Error:
Line 26: cmd.Parameters.AddWithValue("@ecat", cat);
Line 27: cn.Open();
Line 28: int i= cmd.ExecuteNonQuery();
Line 29: cn.Close();
Line 30: return i;
Source File: c:\domains\Paystole.com\wwwroot\App_Code\Dal\DEduCat.cs Line: 28
Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1081596
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +167
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113
DEduCat.DInsert(String cat) in c:\domains\Paystole.com\wwwroot\App_Code\Dal\DEduCat.cs:28
BEduCat.BInsert() in c:\domains\Paystole.com\wwwroot\App_Code\Bal\BEduCat.cs:33
Admin_Education.bntSave_Click(Object sender, EventArgs e) in c:\domains\Paystole.com\wwwroot\Admin\Education.aspx.cs:80
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1025
|
|
|
|
|
|
My ASP.NE Test Page is as follows:
TestPage.aspx:
<%@ Page Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="TestPage.aspx.vb" Inherits="TestPage" title="Test Page"%>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:content id="Content1" contentplaceholderid="MainContent" runat="Server">
<asp:toolkitscriptmanager id="ToolkitScriptManager1" runat="server">
Test Page
<asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional">
<contenttemplate>
<asp:textbox id="txtAddress" runat="server" height="16px" width="200px"><input id="btnSelect" type="button" value="Select" onclick="AddTextBox();" />
<asp:button id="btnSave" runat="server" text="Save">
<script type="text/javascript">
function GetDynamicTextBox(textboxValue) {
//alert('Debug 01' + textboxValue);
var width = document.getElementById("ctl00_MainContent_txtAddress").style.width;
return "<input name = 'Text1' type='text' value = '" + textboxValue + "' style='width:" + width + "';/>"
//alert('Debug 02' + width);
}
function AddTextBox() {
var thisAdd = document.getElementById("ctl00_MainContent_txtAddress");
if (thisAdd.value == 0) return false;
var div = document.createElement('DIV');
div.innerHTML = GetDynamicTextBox(document.getElementById("ctl00_MainContent_txtAddress").value);
document.getElementById("targetDiv").appendChild(div);
document.getElementById("ctl00_MainContent_txtAddress").value = '';
}
function RecreateDynamicTextboxes() {
var txtValues = eval('<%=TxtValues%>');
alert('Debug 02: ' + txtValues);
if (txtValues != null) {
var html = "";
for (var i = 0; i < txtValues.length; i++) {
html += "" + GetDynamicTextBox(txtValues[i]) + " ";
}
document.getElementById("targetDiv").innerHTML = html;
}
}
function pageLoad() {
RecreateDynamicTextboxes();
}
</script>
Now Code Behind (TestPage.aspx.vb) is as follows:
Imports System.Data.SqlClient
Imports System.Web.Script.Serialization
Partial Class TestPage
Inherits System.Web.UI.Page
Protected TxtValues As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim serializer As New JavaScriptSerializer()
Dim textboxValues As String() = Request.Form.GetValues("Text1")
Me.TxtValues = serializer.Serialize(textboxValues)
End Sub
End Class
If I remove "UpdatePanel" and then run it, enter some text in the textbox, click "select" and do this for a few lines and finally click "Save", the PostBack returns the text lines entered.
But when I add "UpdatePanel" back in then it fails on line:
var txtValues = eval('<%=TxtValues%>'); of javascript "function RecreateDynamicTextboxes()" i.e. TxtValues contains nothing after PostBack.
Can I request if someone can suggest ways to make this work please?
mbmirza
|
|
|
|
|
That was way too much code to post and for someone like me to go through.
Plus you didn't wrap your code in <pre></pre> tags to say this is code.
function RecreateDynamicTextboxes() {
var txtValues = eval('<%=TxtValues%>');
alert('Debug 02: ' + txtValues);
if (txtValues != null) {
var html = "";
for (var i = 0; i < txtValues.length; i++) {
html += "
" + GetDynamicTextBox(txtValues[i]) + "
";
}
document.getElementById("targetDiv").innerHTML = html;
}
}
I didn't see a TxtValue in the HTML. All I see is a TxtAddress as something that can postback to the server.
FYI:
When you post back to the server, only the original HTML form elements that the server sent can postback to the server. Dynamic elements created in Javascript cannot post back to the server, because the server dodn't know that they exists.
On a partial postback, or update panel, just the content in the container postback to the server. anything outside the container does nothing.
If you want to use an input element like TxtValue, create it like the TxtAddress and just hide it so it post back.
|
|
|
|
|
Apologies as HTML tags were removed when I added the code. I expected someone will simply cut and paste the .aspx and .aspx.vb pages and run the code.
Basically its a simple example containing a single textbox with a button next to it "select". All of this is inside an Update Panel which inside the Content Page of the Master Page.
The user enters some text in the text box and clicks select button, which calls Javascript routine - AddTextBox which creates a dynamic textbox underneath the orignal textbox and copies the value of text to it. User may continue to add as many text boxes as required and finally click the "Save" button.
The server then processes the dynamic textbox array as follows:
Dim serializer As New JavaScriptSerializer()
Dim textboxValues As String() = Request.Form.GetValues("Text1")
Me.TxtValues = serializer.Serialize(textboxValues)
So the values of textboxes are simply returned in string variable called "TxtValues".
On return the client extracts the values from the variable TxtValues and loops round to redisplay all textboxes as they were originally shown. This is done in Javascript routine - RecreateDynamicTextboxes and the code as you rightly pointed out is:
var txtValues = eval('<%=TxtValues%>');
The problem is that if I remove Update Panel then it all works fine the script reads all textbox values from the variable TxtValues, loops round and re-displays the textboxes. But when I add back the Update Panel the string variable TxtValues contains nothing because the variable is outside of the Panel.
Now I have discovered that if I place the "Save" button outside of the panel then that works but then the whole page blinks which is the main reason I want to use Update Panel.
mbmirza
|
|
|
|
|
So TxtValue is dynamic?
If so, it will never post back to the server, seriously.
You would have to transmit the data via JQUERY Ajax and JSON to a web service, which updates the database.
Or stuff the data in a textbox that comes off the server, and delimit the values to post it back.
Or write a json format text stream to the textbox, and decipher it on the server side.
Feel free to ask for any clarification
|
|
|
|
|
I'm currently designing a page using ASP.NET and JQuery which is very similar to an order form. The page has two ASP.NET Panels; the first one contains ASP.NET controls for some general information. These controls all have validators associated with them, all part of the validation group "vgRequest", along with a validation summary control which is also part of the vgRequest group.
The second Panel contains only HTML text boxes (<input /> ) and two buttons (<button />) . When one of the buttons is clicked, it is supposed to call a JQuery function, however the HTML button is causes the ASP.NET validators to run.
I do not want this to happen as at the very end of the page there is another ASP.NET button which should cause the validation to run. I have tried setting the EnableClientScript property on the validation summary control to False but this didn't help. I've also tried searching on Google but everything I've come across talks about using <asp:Button /> controls.
Is there anyway to prevent normal HTML controls from causes the ASP.NET validators to run? I know I could use <asp:Button /> and set the CausesValidation property to False, but I don't know if this is an option. I'm using the Knockout library and the button I currently have is <button runat="server" data-bind='click: addLine'>Add Line</button> but I haven't figured out a way to add the data-bind='click: addLine' to an ASP.NET button (I have tried OnClickClient='addLine' but this didn't work either.
Any suggestions or information that can help resolve this issue would be greatly appreciated.
Thank You
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
It sounds like your addLine function isn't preventing the default click action. As a result, the button will submit the form, which will cause the validators to run on the server.
According to the Knockout documentation[^], if your addLine method returns true , the default click action will run.
Adding the binding attribute to an ASP.NET button should be as simple as:
<asp:Button runat="server"
CausesValidation="false"
Text="Add Line"
data-bind="click: addLine"
/>
Any attributes which don't map to properties on the control will be passed through unchanged.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Just a stab in the dark here.
onClientClick="jquery_validate(); return false;"
The return false cancels the button click event, which in turn cancels the validation.
[edit]
Or you use a non-button like an image or span element, and bind the click in the jquery validator or the document.ready, so it doesn't act like a HTML button, but fires the event. I think you can fabricate a button using span and some css.
|
|
|
|
|
Hi,
I've a quick question -
I'm having 3 pages - 1) Master Page, 2) Header Page(UserControl) 3)Home Page
I'm using header user control as header tag in master page, and then home page is called from master page as well.
I'm not using header user control page in home page. but my requirement is to call a function in header page from Home page on a button click. How can I do this ?
Need help on this please
|
|
|
|
|
- Make sure the function in the header UserControl is public;
- Add a public property to the code-behind for your master page to expose the header UserControl, using the type defined in the UserControl's code-behind;
- Add the
@MasterType directive[^] to your home page to specify the type of the master page; - You will then be able to access the new property from the home page's
Master property, and from that you will be able to access the function:
Master.HeaderControl.YourFunction()
How to: Reference ASP.NET Master Page Content [^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I do't understand clearly if you can explain more or try post your code.
but maybe you can try use the public word for your function
|
|
|
|
|
Hello Everyone
How to make a Video calling pop up (eg. Skype)if user calls to another user need show a popup window Accept/Deny
Very Urjent
Kindly do the needful
|
|
|
|
|