using runat="server" gives Validation of viewstate MAC failed - c#

Javascript
var form = document.getElementById('date_budget');
pop('', 'exp_upd', '95', '80');
form.action = "test.aspx";
form.target = 'exp_upd';
form.submit();
HTML
<form id="date_budget" name="date_budget" method="post">
<table>
<tr>
<!--#include file="zone.inc" -->
<td id='mlodg_loc'><select name="loc" id="loc">
<option value="Select Location">Select Location</option>
</select></td>
<td>
<select name="month" id="month">
<option value="1">1</option>
</select>
</td>
<td>
<select name="year" id="year">
<option value="2013">2013</option>
</select>
</td>
</tr>
</table>
</form>
The above code opens a popup window, but when I change the html by adding the runat attribute, I am getting “Validation of viewstate MAC failed”, and some extra junk. the modified html is below
<form id="date_budget" name="date_budget" method="post" runat="server">
<table>
<tr>
<!--#include file="zone.inc" -->
<td id='mlodg_loc'><select name="loc" id="loc" runat="server">
<option value="Select Location">Select Location</option>
</select></td>
<td>
<select name="month" id="month" runat="server">
<option value="1">1</option>
</select>
</td>
<td>
<select name="year" id="year" runat="server">
<option value="2013">2013</option>
</select>
</td>
</tr>
</table>
</form>
Is there any workaround to use both the runat server and using the same element in JS, without using those asp tags something like <%= hidBT.ClientID %> I don't want that any other way.

Try to add this <pages enableViewStateMac="false"> in your web.config (or)
Try to Change this <form id="date_budget" name="date_budget" method="post"> to
this <form id="date_budget" name="date_budget" runat="server">
It shouldn't specify method or action

You can try setting the ClientIDMode="Static" on the control or in the #Page directive. That will keep the id of the form as "date_budget".
Otherwise if you don't need the ViewState on the page, then you can disable it in the #Page directive using EnableViewState="false".

Related

I want to block all body after I click any button on page. How I can do it? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
this is button in page if I click any button I wanna to block all body
You could try to add the page/ Form contents to the Fieldset tag and using the JS code, you could try to add the disabled="disabled" attribute on the button click. It could help you disable the controls.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<script>
function myFunction() {
document.getElementsByTagName("fieldset")[0].setAttribute("disabled", "disabled");
}
</script>
</head>
<body>
<h1>Test Form</h1>
<br>
<form>
<fieldset >
<table>
<tr>
<td><label for="name">Enter name:</label></td>
<td><input type="text" name="name" value="" id="name" /></td>
</tr>
<tr>
<td><label for="password">Enter password:</label></td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td><label for="email">Enter Email:</label></td>
<td
><input type="email" name="email" value="" id="mail"/></td>
</tr>
<tr>
<td><label for="gender" class="label">Select Gender:</label></td>
<td>
<input type="radio" name="gender" id="gendermale" value="male"/>
<label for="gendermale">male</label>
<input type="radio" name="gender" id="genderfemale" value="female"/>
<label for="genderfemale">female</label>
</td>
</tr>
<tr>
<td><label for="country" >Select Country:</label></td>
<td>
<select name="country" id="country">
<option value="india">india</option>
<option value="pakistan">pakistan</option>
<option value="africa">africa</option>
<option value="china">china</option>
<option value="other">other</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<div align="right"><input type="submit" id="register_0" value="Submit" onclick="myFunction()"/> </div>
</td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
Output:
You could test this example on your side and further modify the code according your requirements.

Datalist not displaying items ASP.NET

I have a serious problem with data list I HATE IT so much. I have a list of data that displays cart items in a table.. basic right?
Sure, but not for data list! its like data list says I MUST DESTROY YOU. The data list does not show any items that I should display!
Here are some screenshots that will let you understand my issue here.
So basically the items are displayed in VS, but in the web application it doesn't.
PLEASE HELP :(
Here is the code:
<div class="container-sm cart-page">
<table>
<tr>
<th>المنتج</th>
<th>الكمية</th>
<th>السعر الفرعي</th>
</tr>
<asp:DataList ID="DataList1" runat="server" RepeatColumns="1" RepeatLayout="Flow">
<ItemTemplate>
<tr>
<td>
<div class="cart-info">
<img src="http://bestjquery.com/tutorial/product-grid/demo8/images/img-1.jpg" alt="camera">
<div>
<p>Camera 211</p>
<small>السعر: 50 ر.س.</small>
<br>
حذف
</div>
</div>
</td>
<td>
<input type="number" value="1" min="1" max="10"></td>
<td>50 ر.س.</td>
</tr>
</ItemTemplate>
</asp:DataList>
</table>
<div class="total-price">
<table>
<tr>
<td class="titles">السعر الفرعي</td>
<td>150 ر.س.</td>
</tr>
<tr>
<td class="titles">VAT</td>
<td>22.50 ر.س.</td>
</tr>
<tr>
<td class="titles">المجموع</td>
<td>172.50 ر.س.</td>
</tr>
<tr>
<td>
<a href="store.aspx">
<button type="submit" class="btn btn-primary btn-continue-shopping">إكمال التسوق</button>
</a>
</td>
<td>
<a href="checkout.aspx">
<button type="submit" class="btn btn-primary btn-checkout">إكمال الدفع</button>
</a>
</td>
</tr>
</table>
</div>
</div>
You need to set the DataSource property with some list or table of data.
Here is a link to the MSDN article: https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.basedatalist.datasource?view=netframework-4.8#System_Web_UI_WebControls_BaseDataList_DataSource
What is your data source? Are you using a database?
If you do not have a database you can mockup a dataset in XML, JSON, or CSV and then deserialize into your code.
I believe that you can bind anything that implements IList.

Trying to open popup through jquery containing html syntax

I'm Trying to open popup through jquery containing html syntax.but not getting proper idea.I have open an alert as shown below ex but how to open this HTML.The example code which i have shared gets data dynamically in mvc and on clicking that hyperlink i want to open an html page which should also contain dynamically data 'Html' code is given below.Any idea would be appreciated.
HTML
<body>
<table>
<tr>
<td>zone</td><td>Date</td>
</tr>
<tr>
<td>CreatedBy</td><td>CreatedDate</td>
</tr>
<tr>
<td>ClosedBy</td><td>ClosedDate</td>
</tr>
<tr>
<td>Pririty</td><td>IssueType</td>
</tr>
<tr>
<td>Branch/Location</td><td>IssueDescription</td>
</tr>
</table>
<select>
<option value="Open">Open</option>
<option value="Closed">Closed</option>
</select>
<textarea>Description</textarea>
<select>
<option value="Open">Open</option>
<option value="Closed">Closed</option>
</select>
<textbox>Attachment</textbox>
<input type="submit" value="submit"/>
</body>
asp.net mvc
<td id="statusdiv_#item.EscId" class="statusdiv">#Html.ActionLink(#Html.DisplayFor(model => item.Status).ToString(), "Escalation")</td>
jquery
$('.statusdiv').click(function () {
alert('hello');
});

Page is not loading at time in asp.net

In my web page i am using panel then div. panel is loading first and then div tag, but I want two at a time. I tried Ajax update process and java script Loading image but not working.
please help me.
<div class="container-fluid contentStart" >
<div class="row-fluid">
<div data-layout='{"type": "border", "hgap": 3, "vgap": 3}' class="layout mailVertical">
<asp:Panel ID="pnlRefDet" runat="server" class="layout mailVertical" >
....
</asp:panel>
<div class="west" style="background-color:#FAFAFA; width:32%" runat="server" id="divMessageInbox">
.....
</div>
</div>
</div>
</div>
You can put both in table then it will load at once
<table>
<tr>
<td>
panel goes here
</td>
</tr>
<tr>
<td>
div goes here
</td>
</tr>
</table>

create dynamic html elements and add to table asp.net

I used to some thing like this in jsp.
<%#page language="java" import="java.util.*"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%# page errorPage="/showError.jsp" %>
<%
String path = request.getContextPath();
%>
<sql:query var="rs" dataSource="jdbc/production">
select id,location,zone,ifnull(DATE_FORMAT(date_recp,'%m/%d/%Y'),'00-00-0000') as date_recp,qry_id ,cust_name,qry_recvd,qry_mode,ifnull(DATE_FORMAT(start_date,'%m/%d/%Y'),'00-00-0000') as start_date,
timing,qry_type,qry_cat,qry_det,ifnull(DATE_FORMAT(date_esclation,'%m/%d/%Y'),'00-00-0000') as date_esclation,ifnull(DATE_FORMAT(date_recp_ho,'%m/%d/%Y'),'00-00-0000') as date_recp_ho,
ifnull(DATE_FORMAT(date_recp_ho,'%m/%d/%Y'),'00-00-0000') as final_date,remarks,qry_stat from cust_supp where final_date is null or final_date='0000-00-00'
</sql:query>
<html>
<head>
<title>Customer Support Search Operation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<%= path %>/js/style.css" />
<style type="text/css" title="currentStyle">
#import "<%= path%>/css/demo_table.css";
#import "<%= path%>/css/demo_table_jui.css";
#import "<%= path%>/css/jquery-ui-1.8.20.custom.css";
#import "<%= path%>/css/TableTools.css";
#import "<%= path%>/css/TableTools_JUI.css";
</style>
<script type="text/javascript" src="<%= path%>/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%= path %>/js/tcal.js"></script>
<link rel="stylesheet" type="text/css" href="<%= path %>/css/tcal.css" />
<script src="<%= path%>/js/jquery.dataTables.js" type="text/javascript"></script>
<script src="<%= path%>/js/ZeroClipboard.js" type="text/javascript"></script>
<script src="<%= path%>/js/TableTools.js" type="text/javascript"></script>
<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/styles.css" rel="stylesheet" type="text/css" />
<script src="<%=path%>/js/tinybox.js" type="text/javascript"></script>
<script src="<%= path%>/js/send_data.js"></script>
</head>
<div class="brand" style="background:url('<%=path%>/images/head.jpg') no-repeat ;"></div>
<body>
<div class="forms">
<form style="height:450pt;width:95%;margin-left:5pt;margin-top:0" name ="form" action="<%=path%>/Download">
<input type="hidden" name="query" value="q0" />
<input type="hidden" name="dwld" value="cust_supp" />
<table width="95%" id="dataTable" class="display">
<thead>
<tr>
<th width="20pt"><b>S.no</b></th>
<th><b>Query ID</b></th>
<th><b>Zone</b></th>
<th><b>Location</b></th>
<th><b>Customer Name</b></th>
<th><b>Query Received</b></th>
<th><b>Date of Receipt</b></th>
<th><b>Mode of Query</b></th>
<th><b>Start Fall-Up Date</b></th>
<th><b>Timing</b></th>
<th><b>Query Type</b></th>
<th><b>Query Category</b></th>
<th><b>Query Details</b></th>
<th><b>Date of Escalation</b></th>
<th><b>Date of Receipt HO/Client/Bank</b></th>
<th><b>Final Date</b></th>
<th><b>Remarks</b></th>
<th><b>Query Status</b></th>
<th><b>Update</b></th>
</tr>
</thead><tbody>
<c:forEach var="row" items="${rs.rows}">
<tr>
<td>${row.id}</td>
<td><span>${row.qry_id}</span></td>
<td><span>${row.zone}</span></td>
<td><span>${row.location}</span></td>
<td><span class="editable">${row.cust_name}</span></td>
<td><select name="query_rcvd" >
<option value="${row.qry_recvd}" selected>${row.qry_recvd}</option>
<option value="Client">Client</option>
<option value="HO">HO</option>
<option value="Other">Other</option>
</select></td>
<td align="right"><input type="text" name="date" class="tcal" value="${row.date_recp}" /></td>
<td><select name="mode" >
<option value="${row.qry_mode}" selected>${row.qry_mode}</option>
<option value="phone">Phone</option>
<option value="E-mail">E-mail</option>
</select></td>
<td><input type="text" name="date" class="tcal" value="${row.start_date}"/></td>
<td><span class="editable">${row.timing}</span></td>
<td><select name="nature">
<option value="${row.qry_type}" selected>${row.qry_type}</option>
<option value="ECS Debit">ECS Debit</option>
<option value="ECS Credit">ECS Credit</option>
<option value="ASP">ASP</option>
<option value="MF">MF</option>
<option value="Retail">Retail</option>
</select></td>
<td><select name="category">
<option value="${row.qry_cat}" selected>${row.qry_cat}</option>
<option value="Status of the Transaction" >Status of the Transaction</option>
<option value="Mandate Related Queries">Mandate Related Queries</option>
<option value="Mandate Re-submission Cases">Mandate Re-submission Cases</option>
<option value="Wrong Reason Code Given By The Bankers">Wrong Reason Code Given By The Bankers</option>
<option value="Txn bounced at our end but cust bank a/c debited">Txn bounced at our end but cust bank a/c debited</option>
<option value="Extra debit in the bank account">Extra debit in the bank account</option>
<option value="Credit Query">Credit Query</option>
<option value="R7">R7 Report</option>
</select></td>
<td><span class="editable">${row.qry_det}</span></td>
<td><input type="text" name="date" class="tcal" value="${row.date_esclation}"/></td>
<td><input type="text" name="date" class="tcal" value="${row.date_recp_ho}"/></td>
<td><input type="text" name="date" class="tcal" value="${row.final_date}"/></td>
<td><span class="editable">${row.remarks}</span></td>
<td><span class="editable">${row.qry_stat}</span></td>
<td><input type="button" class="tab_buttons" value="Update"/></td>
</tr>
</c:forEach>
</tbody>
</table>
</form>
</div>
</body>
</html>
That creates a page from MySql DB which contains select and input elements within a html table, Now I want to achieve the same in an aspx page. I tried to add dynamically from code behind, but that's completely mixing c# with html, I don't want that, As I am new, someone suggested me spark, they said it worked like jstl which I used above, I tried but spark is not getting into my head, a simple simple simple example plsss. Or any other better way to achieve that. MVC not involved in this so that I can use razor.
Thank you

Categories

Resources