|
Steve, many thanks for the insights you give from someone who's worked on non-trivial applications in both technologies. Your comments confirm what I'd suspected. I work with lots of smaller clients - in most cases completely non-technical - and though I make it clear in my proposals I'll be using WebForms technology, this has never been an issue and the customers are happy with the end result.
One area I might slightly disagree is in your comments about Javascript. The reality is that if you need to create a website-based solution that loads without requiring additional support software on the client machine, there's not a lot of options if you need a functionally rich application. Despite all the many detractors from Javascript itself on this site and elsewhere, the biggest problem I've encountered is the scores of bolt-on "frameworks" each claiming to fill in the gaps in "easy" functionality from raw Javascript. A lot of these are bloated, inefficient, bug-ridden, and poorly documented. Even a good developer can struggle to build a decent site using (where I agree with you) low quality tools. Sadly there are too many "developers" who are not good, and the good ones get tainted with the perception that web developers can't deliver a decent product.
My feeling is that the rush of new frameworks and languages has slowed down a little in the past couple of years. Some technologies are beginning to mature and recognition is spreading that the way we approached development a few years ago (just grab components off the freeware shelf, together with whatever framework dependencies they dragged with them, and throw it all together) won't cut the mustard.
|
|
|
|
|
DerekT...
I should be thanking you for your reply...
You are part of a growing chorus of professional technicians who are starting to realize that increased complexity does not always translate into increased capabilities or even ease-of-use.
Most of the original complaints regarding WebForms were legitimate. However, they were primarily targeted at the internals of the environment, which in many cases had work-arounds so one could avoid their pitfalls. However, as I had mentioned, Microsoft worked to improve these internals and did a rather good job of it.
Had the community not simply walked away from the WebForms environment, it would have received more refinements.
Of course we have the Microsoft issue where the company continuously "throws the baby out with the bathwater" when introducing new refinements and\or products. This corporate problem did not help their case to maintain WebForms as a viable development environment.
As to JavaScript, I understand your disagreement with my position. However, I was not referring to the necessities of using the language for hosting capabilities at the web client but instead its general use as a major development language through the use of all these cryptic frameworks.
Doing so has changed the orientation from server-side supported applications back the "fat client" model, which is the very thing that was fought against in the late 1990s and early to mid 2000s. Professionals that time all agreed that the "fat client" model was unwieldy and presented more issues than it was worth. Thus, we stuck with the "thin client" model, which I still adhere to.
When MVC emerged, many professionals used it as an excuse to blame the inefficiencies of WebForms as an environment that was not workable while laying the blame on its internal model (web-page\code-behind) as the basis for many poorly written applications. However, this aspect of WebForms was never the fault of the design but the result of poor development techniques. The Code-Behind component side of things was only intended to be a dispatcher while also handling immediate display constructs. Nonetheless, many developers merely stuck a whole lot of code in these server-side modules making WebForms look more like a whale than it actually was.
MVC brought JavaScript into forefront as a major development language for which it was never intended and it has been responsible in large part for the mess that current web development has found itself in.
Despite all of the crowing regarding MVC, I have never found a single analysis of the performance aspects of it against WebForms with the exception of a single professional's curiosity who bench-marked an in-house application in both environments. He found that after 100 concurrent users in either application there was absolutely no difference in performance between the WebForms and MVC applications.
To me, WebForms was and still is the zenith of web development on the current Internet topologies. Considering that the Internet was never designed to support what is being thrown over it today, WebForms was a very successful implementation to make such development a far easier and more approachable technology when compared to anything MVC has to offer.
Steve Naidamast
Sr. Software Engineer
Black Falcon Software, Inc.
blackfalconsoftware@outlook.com
|
|
|
|
|
Error:'D:\test_data\sample_bulk_upload_File.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides
code::
path = TextBox3.Text
s1 = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" + path + ";Extended Properties=""Excel 8.0;HDR=YES;"""
Dim OLEcon As OleDb.OleDbConnection = New OleDb.OleDbConnection(s1)
Dim OLEcmd As New OleDb.OleDbCommand
Dim OLEda As New OleDb.OleDbDataAdapter
Dim OLEdt As New DataTable
Dim sql As String
Dim resul As Boolean
OLEcon.Close()
Try
OLEcon.Open()
With OLEcmd
.Connection = OLEcon
.CommandText = "Select * from [data1$]"
End With
OLEda.SelectCommand = OLEcmd
OLEda.Fill(OLEdt)
For Each r As DataRow In OLEdt.Rows
|
|
|
|
|
The path D:\test_data\sample_bulk_upload_File.xls is valid on your development machine, and becomes invalid once deployed to the production server. You need to provide a path which is valid in the context of executing environment.
The best solution for this kind of issue is to avoid hard-coding the path. Better include it in a configuration file, of which you can have separate versions for development and production environments.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Hi Phil,
Thank you for your comments, I have already tried the file upload tool to perform this but that was not working , hence I am using static path or physical path.
Do you have any example for this type of issue?
With Regards
Rama
|
|
|
|
|
|
I have a datatable like this
----------------------------
STID NAME DOB SBCD
----------------------------
1001 XXX DMY AAAA
1001 XXX DMY BBBB
1001 XXX DMY CCCC
1001 XXX DMY DDDD
1002 YYY DMY AAAA
1002 YYY DMY BBBB
1002 YYY DMY CCCC
1003 ZZZ DMY AAAA
1003 ZZZ DMY BBBB
1003 ZZZ DMY CCCC
1003 ZZZ DMY DDDD
1003 ZZZ DMY EEEE
I want to convert this datatable into following format and bind it to gridview.
----------------------------------------------------------------------
| STID | NAME / DOB | SUBJECTS |
|------|----------------|--------------------------------------------|
|1001 | XXX | AAAA BBBB CCCC DDDD |
| | DMY | |
|------|----------------|--------------------------------------------|
|1002 | YYY | AAAA BBBB CCCC |
| | DMY | |
|------|----------------|--------------------------------------------|
|1003 | ZZZ | AAAA BBBB CCCC DDDD EEEE |
| | DOB | |
|------|----------------|--------------------------------------------|
|
|
|
|
|
Hi Friends,
I have web application along with few Class Library Projects.
I need help in implementing the following 2 points.
i) I have method written in Master Page code behind, I need to access this method from all my content pages.
ii) I need to access Master Page (like this.Master) from my another Code library project in the same Solution.
Kindly suggest on the solution.
Thanks in Advance,
Regards,
Priya.
|
|
|
|
|
If you use the MasterType directive it will let you use strongly-typed master pages. If your master page is;
using System.Web.UI;
namespace WebApplication1
{
public partial class SiteMaster : MasterPage
{
public string SayHello()
{
return "Hello";
}
}
}
Add the MasterType directive to the top of your content page
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%@ MasterType TypeName="WebApplication1.SiteMaster" %>
In your page you can now access the "SayHello" function on your master page
protected void Page_Load(object sender, EventArgs e)
{
string text = Master.SayHello();
}
If you don't want to use the MasterType you can still acccess the master page code but you have to cast yourself
var master = (SiteMaster) Master;
string text = master.SayHello();
If you have code in the master page that you need to access from non-page classes then the master page is the wrong place for that code. Put it in its own class rather than the master page.
|
|
|
|
|
Thank you so much.
I will try this.
Yes I have code 2 methods in Master page, which i need to access from content pages, But i will have more than 50 Content Pages. So i am planning to declare in Master and call from other pages.
What will be the best approach for this.
Actually I am thinking to write the methods in Class Library and access from all the aspx.cs pages. But the methods are calling one of the control in the Master page like this.Master.CtrlName. But this i couldnt write in my class library class file.
Thanks Again.
|
|
|
|
|
Add an interface to your class library which exposes the relevant methods.
Have the methods in your class library take an instance of that interface as a parameter, and call the methods on it.
Make the master page implement that interface.
Pass the master page to the class library methods.
Class library:
public interface ISiteMaster
{
void DoSomething();
string ReturnSomething();
}
public class SomeClass
{
public string Foo(ISiteMaster master)
{
master.DoSomething();
return master.ReturnSomething();
}
} Web application:
public partial class SiteMaster : MasterPage, ISiteMaster
{
public void DoSomething() { ... }
public string ReturnSomething() { ... }
}
public partial class HomePage : Page
{
protected void Page_Load(object sender, EventArgs e)
{
var helper = new SomeClass();
string value = helper.Foo(Master);
string value = helper.Foo((ISiteMaster)Master);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello Friends,
I have asp.net website and have few class libraries in the same solution.
I am trying to store a database retrieved datatable (it contains only one column) into Array variable and assigning the array into Session.
This code is in my aspx.cs page.
<b>Code is aspx.cs below:</b>
DataRow[] foundAuthors = dtPermission.Select("Value = '" + Permission + "'");
if (foundAuthors.Length != 0)
{
ArrayList permlist = new ArrayList();
foreach (DataRow dr in dtPermission.Rows)
{
permlist.Add(dr["Value"].ToString());
}
SessionHandler s = new SessionHandler();
s.SetSession(permlist, "sPermList");
I have the following code in the class library. But in this code the session value i am not sure how to assign as array list in test method. currently it is showing as string and not working. Please help.
<b>Class Library Code:</b>
public class SessionHandler : IRequiresSessionState
{
public SessionHandler() { }
public object GetSession(string key)
{
object session = HttpContext.Current.Session[key];
return session;
}
public void SetSession(object data, string key)
{
HttpContext.Current.Session.Add(key, data);
}
public bool Test(string sessionKey,string perValue)
{
string ss = GetSession(sessionKey).ToString();
--Here need to assign session value to array list and compare the perValue against array list (or) if we can directly compare session stored value and return true / false
return true;
}
}
Thanks in Advance,
Priya.
-- modified 14-Nov-19 6:23am.
|
|
|
|
|
How about:
public bool Test(string sessionKey, string perValue)
{
System.Collections.IEnumerable list = (System.Collections.IEnumerable)GetSession(sessionKey);
foreach (string item in list)
{
if (item == perValue)
{
return true;
}
}
return false;
} NB: You should avoid using ArrayList . It's an old collection from before the introduction of generics. Use List<T> instead.
NB2: The IRequiresSessionState on your SessionHandler class won't make any difference. That interface is only used on the IHttpHandler which handles the request. For a WebForms page, that is controlled by setting the EnableSessionState property in the <%@ Page ... %> directive.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello Richard,
Thanks lot and lot. It worked like charm!! This is saved my time, i was searching for a day on this.
Reg. the Note 1 : I agree and follow that.
Reg. the Note 2, I am not really understanding, if you could elaborate that will be great help to me. Is the approach I am following will hit performance,
Thanks in Advance.
Priya.
|
|
|
|
|
Every request to your application is handled by an instance of a class which implements the IHttpHandler interface[^].
For a WebForms page (.aspx ), that class will be derived from the System.Web.UI.Page class[^]. Session state is controlled by setting the EnableSessionState attribute on the @ Page directive[^]. It can be set to "True", "False", or "ReadOnly". The compiler will automatically implement the correct session state interface on the generated class for you.
For other handlers, session state is enabled or disabled depending on whether the handler class implements the IRequiresSessionState interface[^], or the IReadOnlySessionState interface[^] if it doesn't add or update any session data.
Implementing the IRequiresSessionState interface in a class which is not the handler for the current request will have no effect.
ASP.NET Session State Overview | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for brief explanation.
|
|
|
|
|
what is major difference between blazor server app and asp.net mvc razor app?
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
|
every interaction is a network call
if i have slow internet then basic functions will take forever to execute
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
My take on it was that with Blazer, you can make client side apps sort of like Angular, in which you can type your client side code in c# instead of JavaScript or TypeScript, and a Blazer utility sort of like Babel will translate your c# code into current and backwards compatible JavaScript, and automatically insert it into the server side generated HTML, and transmit it back to the client.
This reminds of .Net MVC, in which you can add React client and server via NuGet packages, and write react modules to insert on Razor pages, in which Babel will translate the React module into JavaScript and integrate into the server generated HTML and send the page to the client. So instead of client generating React JavaScript, it's done on the server side, so that .Net can keep track of it.
Babel is a translator, that can generate backwards compatible JavaScript from ECMAScript 2015+
What is Babel? · Babel
So in my mind from what I read of it, Blazer is sort of like ReactJS using Babel, or AngularJS in which you can create a single page application SPA within a single Razor page all in c# without the steep learning curve of ReactJS or AngularJS.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I have a GridView with template fields and one of the template field is a dropdownlist which is dynamically added into the gridview control. It's working properly on page load when I click the button control to the get the values from the template fields it will throw a null reference exception. Please correct my error, I am in pathetic situation. I attached the source code.
Regards
rites|Alert Moderators
asolmduasolmdu
None
0 Points
1 Post
gridview with dynamic dropdownlist control null exception
33 minutes ago|LINK|157.50.247.59
I have a GridView with template fields and one of the template field is a dropdownlist which is dynamically added into the gridview control. It's working properly on page load when I click the button control to the get the values from the template fields it will throw a null reference exception. Please correct my error, I am in pathetic situation. I attached the source code.
Regards
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
OnRowCreated="GridView1_RowCreated">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="id" runat="server" Text='<%# Eval("RGNO") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="name" runat="server" Text='<%# Eval("NAME") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lastname" runat="server" Text='<%# Eval("DOB") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindGridView();
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlResult = new DropDownList();
ddlResult.ID = "ddlResult";
ddlResult.Items.Insert(0, new ListItem("PASS", "0"));
ddlResult.Items.Insert(1, new ListItem("FAIL", "1"));
PlaceHolder p = (PlaceHolder)e.Row.FindControl("PlaceHolder1");
p.Controls.Add(ddlResult);
}
}
private void BindGridView()
{
GridView1.DataSource = CreateDataSource();
GridView1.DataBind();
}
public DataTable CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("RGNO", typeof(string)));
dt.Columns.Add(new DataColumn("NAME", typeof(string)));
dt.Columns.Add(new DataColumn("DOB", typeof(string)));
dr = dt.NewRow();
dr["RGNO"] = "1001";
dr["NAME"] = "PRAKASH";
dr["DOB"] = "10-10-2003";
dt.Rows.Add(dr);
return dt;
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
DropDownList dd1 = (DropDownList)row.FindControl("ddlResult");
Response.Write(dd1.SelectedItem.Text);
}
}
|
|
|
|
|
i want to add video calling "one to one and one to many" function on my web page using asp.net bt i dont understand how i can add this on my web site
|
|
|
|
|
You can either buy something that supports what you want to do, or spend years writing millions of lines of code spanning many different technologies to achieve this.
|
|
|
|
|
|
This my aspx code
<table align="center">
<tr valign="top">
<td>
<asp:DataList ID="gv1" runat="server" RepeatColumns="1" RepeatDirection="Horizontal">
<HeaderTemplate>
Our Tutors List</HeaderTemplate>
<ItemTemplate>
<table width="600px" border="2" align="center">
<tr align="center">
<td width="100%" valign="top" style="font-size: 15px">
Name: <%#DataBinder.Eval(Container.DataItem, "FirstName")%> <%#DataBinder.Eval(Container.DataItem, "LastName")%>
<%--Mobile: <%#DataBinder.Eval(Container.DataItem, "MobileNo")%>
Email Id: <%#DataBinder.Eval(Container.DataItem, "EmailId")%> --%>
</td>
</tr>
<tr>
<td>
Qualification: <%#DataBinder.Eval(Container.DataItem, "Qualification")%>
Experience: <%#DataBinder.Eval(Container.DataItem, "Experience")%>
</td>
</tr>
<tr>
<td>
Subjects:
<%#DataBinder.Eval(Container.DataItem, "Subjects")%>
<%--Created Date: <%#DataBinder.Eval(Container.DataItem, "CreatedDate")%>--%>
</td>
</tr>
<tr>
<td>
Locations:
<%#DataBinder.Eval(Container.DataItem, "Location")%>
</td>
</tr>
<tr>
<td>
Description:
<%#DataBinder.Eval(Container.DataItem, "Description")%>
</td>
</tr>
</table><br /><br />
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>
<table width="100%" border="0">
<tr bgcolor="" align="center">
<td>
<asp:LinkButton ID="lnkbtnPrevious" runat="server" Text="<" OnClick="lnkbtnPrevious_Click"></asp:LinkButton>
</td>
<td>
<asp:DataList ID="dlPaging" runat="server" RepeatDirection="Horizontal" OnItemDataBound="dlPaging_ItemDataBound"
OnItemCommand="dlPaging_ItemCommand" OnSelectedIndexChanged="dlPaging_SelectedIndexChanged"
UseAccessibleHeader="True">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnPaging" runat="server" CommandArgument='<%#Eval("PageIndex")%>'
CommandName="lnkbtnPaging" Text='<%#Eval("PageText")%>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</td>
<td>
<asp:LinkButton ID="lnkbtnNext" runat="server" Text=">" OnClick="lnkbtnNext_Click"></asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
<aspx.cs code="">
using System;
using System.Data;
using System.Web.UI.WebControls;
public partial class MathsTutors : System.Web.UI.Page
{
PagedDataSource pds = new PagedDataSource();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
ClsTutorDetails tutor = new ClsTutorDetails();
DataTable dt = tutor.GetAllTutors("Active");
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
pds.PageSize = 12;
pds.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pds.IsLastPage;
lnkbtnPrevious.Enabled = !pds.IsFirstPage;
gv1.DataSource = pds;
gv1.DataBind();
if (dt.Rows.Count <= 12)
{
dlPaging.Visible = false;
lnkbtnNext.Visible = false;
lnkbtnPrevious.Visible = false;
}
else
{
dlPaging.Visible = true;
lnkbtnNext.Visible = true;
lnkbtnPrevious.Visible = true;
}
doPaging();
}
#region
private void doPaging()
{
DataTable dt = new DataTable();
dt.Columns.Add("PageIndex");
dt.Columns.Add("PageText");
for (int i = 0; i < pds.PageCount; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = i + 1;
dt.Rows.Add(dr);
}
dlPaging.DataSource = dt;
dlPaging.DataBind();
}
public int CurrentPage
{
get
{
if (this.ViewState["CurrentPage"] == null)
return 0;
else
return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
}
set
{
this.ViewState["CurrentPage"] = value;
}
}
protected void lnkbtnPrevious_Click(object sender, EventArgs e)
{
CurrentPage -= 1;
BindData();
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
CurrentPage += 1;
BindData();
}
protected void dlPaging_SelectedIndexChanged(object sender, EventArgs e)
{
CurrentPage = 0;
BindData();
}
protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("lnkbtnPaging"))
{
CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
BindData();
}
}
protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
{
LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
{
lnkbtnPage.Enabled = false;
lnkbtnPage.Font.Bold = true;
}
}
#endregion
}
|
|
|
|
|