HTML TABLE SCROLL BAR
<style>
.table-container {
width: 100%;
overflow-x: auto; /* Enables horizontal scrolling */
border: 1px solid #ddd;
}
</STYLE>
<div class="table-container">
table
</div>
HTML TABLE SCROLL BAR
<style>
.table-container {
width: 100%;
overflow-x: auto; /* Enables horizontal scrolling */
border: 1px solid #ddd;
}
</STYLE>
<div class="table-container">
table
</div>
Database Create
Student : roll , name , city , cost
Fix 6 Value in Database Record
====================================================================
Default.aspx Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="WebApplication1._default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
OnRowDataBound = "OnRowDataBound" ShowFooter="True">
<Columns>
<asp:BoundField DataField="roll" HeaderText="Roll" ItemStyle-Width = "100">
<ItemStyle Width="100px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="name" HeaderText="Name" ItemStyle-Width = "100">
<ItemStyle Width="100px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="city" HeaderText="Name" ItemStyle-Width = "100">
<ItemStyle Width="100px"></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("cost") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>
<html>
<head>
<script language="JavaScript">
function display(name,m1,m2)
{
var total;
total=parseInt(m1)+ parseInt(m2);
document.write(name + "<br>" + total );
}
</script>
</head>
<body>
enter your name : <input type="text" id="t1"> <br>
enter your m1: <input type="text" id="t2"> <br>
enter your m2: <input type="text" id="t3"> <br>
<input type="button" value="submit" onclick="display(document.getElementById('t1').value , document.getElementById('t2').value , document.getElementById('t3').value , )">
</body>
</html>
STEP 1 CREATE PANEL CONTROL
STEP 2 UNDER PANEL CONTROL CREATE ALL FORM AND DESIGN
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="SHOW DATA" Width="157px" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="SEND MAIL" Width="161px" />
<br />
<br />
<br />
<asp:Panel ID="pnlContents" runat="server" style="border-style: ridge;padding:10px;">
<h1>Customer Generate Bill </h1> <br />
<address>Narula Business Center , Near Lokmat Square </address>
<br />
<b>Mobile No. 8411064860</b>
<hr />
<asp:FormView ID="FormView1" runat="server">
<ItemTemplate>
Student Information Details
<br />
<br />
<b>Name of Customer : </b> <asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>'></asp:Label> <br />
<b>Customer City : </b> <asp:Label ID="Label2" runat="server" Text='<%# Eval("city") %>'></asp:Label> <br />
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</form>
</body>
</html>
=================== C# Coading ========================
using System.Data.SqlClient;
using System.IO;
using System.Net.Mail;
Coding for send button
protected void Button2_Click(object sender, EventArgs e)
{
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
pnlContents.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
SmtpClient smtpClient = new SmtpClient("nrsolution4u-student.com", 25);
smtpClient.Credentials = new System.Net.NetworkCredential("contact@nrsolution4u-student.com", "password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mailMessage = new MailMessage("contact@nrsolution4u-student.com", "nileshimp2015@gmail.com");
mailMessage.Subject = "Domain Testing";
mailMessage.Body = sw.ToString();
mailMessage.IsBodyHtml = true;
smtpClient.Send(mailMessage);
}
}
}
100%
Placement Training Program |
Mr. Nilesh Gupta Founder , NRsolution4u http://nrsolution4u.com/prayatn/ |
Step-1
Create Controller [ StudentController ]
Step-2
Create View Page [ Empty without Model ]
ViewResult - Represents HTML
and markup.
Controller
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public ViewResult Index()
{
ViewBag.ItemList = "Computer
Shop Item List Page";
return View();
}
}
}
Index.cshtml (View Page Code)
@{
Layout = null;
}
<!DOCTYPE html>
<html><body> @ViewBag.ItemList </body> </html>
EmptyResult - Represents no
result.
Note : Only change controller . Index.cshtml
code as it is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public EmptyResult Index()
{
ViewBag.ItemList = "Computer
Shop Item List Page";
return new EmptyResult();
}
}
}
Output: It will return a blank page with no result.
RedirectResult - Represents a redirection to a new URL.
Controller Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public RedirectResult Index()
{
//return
Redirect("Home/Contact");
return
Redirect("http://nileshsir.com");
}
}
}
JsonResult - Represents a JavaScript Object
Notation result that can be used in an AJAX application.
JSON Result returns simple text file
format and key value pairs. Sometimes you may want to return data in JSON
Format and that situation you JSONResult is the best option.
Controller Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public JsonResult Index()
{
Employee emp = new Employee() //
class create inside controller
{
ID = "Emp23",
Name = "Steven
Clark",
Mobile = "825415426"
};
return
Json(emp, JsonRequestBehavior.AllowGet);
}
public class Employee
{
public string ID { get; set; }
public string Name { get; set; }
public string Mobile {
get; set; }
}
}
}
Output :
{"ID":"Emp23","Name":"Steven Clark","Mobile":"825415426"}
JavaScriptResult - Represents a
JavaScript script.
It
returns java script that can be executed on the client browser. It sends
javascript content in response to browser. This block allow you to execute java
script on client at run time.
Controller Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpGet]
public JavaScriptResult
WarningMessage()
{
var msg = "alert('Are
you sure want to Continue?');";
return new JavaScriptResult(){ Script = msg
};
}
}
}
Index.cshtml Code
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script>
$(document).ready(function () {
$("button").click(function () {
$.getScript("/Student/WarningMessage");
});
});
</script>
</head>
<body>
<div>
@ViewBag.ItemList
</div>
<button>Show
Message</button>
</body>
</html>
ContentResult - Represents a text
result.
It returns user-defined content
type. It is useful when you want to send some plain text message to browser
screen.
Controller Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public ContentResult Index()
{
return Content("Hello
ASP.NET MVC 5");
}
}
}
INDEX.cshtml
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div>
@ViewBag.ItemList
</div>
</body>
</html>
FileResult - Represents a downloadable file (with the binary
content).
It represents the content of the
file.
Controller Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpGet]
public FileResult Download()
{
byte[] fileBytes =
System.IO.File.ReadAllBytes(@"D:\testdata\demo.txt");
string filename = "demo.txt";
return
File(fileBytes, filename); // direct open file data
return
File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, filename);
//download file in browser
}
}
}
Index.cshtml code
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div>
@ViewBag.ItemList
@Html.ActionLink("Download
Text File", "Download", "Student")
</div>
</body>
</html>
PartialViewResult
Step 1: Add a partial
page. Go to Solution Explorer Shared. Right-click on
it and select Add View.
Step 2: Create
partial view page as described in this picture.
Step 3: Add the following
code in message.cshtml
page.
<h1> This is
PartialViewResult Example Output. </h1>
Step 4 : Controller Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class StudentController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpGet]
public PartialViewResult
messagepage()
{
return
PartialView("message");
}
}
}
Step -5
Index.cshtml code
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div>
@ViewBag.ItemList
@{
Html.RenderAction("messagepage", "Student");
}
</div>
</body>
</html>
HTML TABLE SCROLL BAR <style> .table-container { width: 100%; overflow-x: auto; /* Enables horizontal s...