process html form with asp.net c# - asp.net

I have the following table which sits inside an asp.net form. Im trying to process it using an onclick event on a button. but the elements are html text boxes and html check boxes all with names that are arrays
ive tried doing this
for(int i = 0; i < Request["pageimagesOrder"].Length; i++)
{
Response.Write(Request["pageimagesOrder"][i]);
}
but it just fell over. Im sure its something simple but like all things, there only simple if you know
thanks
<table>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/1.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[1]" value="1 "></td>
<td width="100" valign="top"><input type="checkbox" value="1" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/2.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[2]" value="2 "></td>
<td width="100" valign="top"><input type="checkbox" value="2" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/3.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[3]" value="3 "></td>
<td width="100" valign="top"><input type="checkbox" value="3" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/5.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[5]" value="4 "></td>
<td width="100" valign="top"><input type="checkbox" value="5" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/7.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 2</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[7]" value="5 "></td>
<td width="100" valign="top"><input type="checkbox" value="7" name="pageimagesDelete[]" /></td>
</tr>
</table>

You are actually naming them with the brackets []
If you write
Response.Write(Request["pageimagesOrder[1]"]) in code behind you will get a value.

You'll need to do:
Response.Write(Request["pageimagesOrder[" + i + "]"]);
That'll give you the correct naming :)

Related

Removing Extra Spacing Between Lines - Website Code

I'm trying to build a table in my email host for a future marketing email and I'm so darn close to finishing it up - but there's one last item that's stumping me. I'm trying to find a way to remove the extra spacing between the bullets - I know the text itself is single spaced like I want, but I don't want there to be double spacing of sorts between text items or bullets. Is there a small bit of code I can add into the below to adjust spacing between bullets to single or perhaps 1.5x?
<table>
<tbody>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:normal"><span style="font:14px arsenal"><span
style="color:#86c8c5">Cruelty Free</span></span>
</span>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:normal"><span style="font:14px arsenal"><span
style="color:#86c8c5">Vegan Friendly</span></span>
</span>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:1"><span style="font:14px arsenal"><span
style="color:#86c8c5">Refillable Bottle for Life</span></span>
</span>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:1"><span style="font:14px arsenal"><span
style="color:#86c8c5">Soothing Yuzu and<br />
Rice Water Formula</span></span>
</span>
</td>
</tr>
</tbody>
</table>

Open IE and Interact with Web Form using Excel VBA

I'm trying to create an excel spreadsheet with a landing page where I input a specific week number, period number and/or year.
I would then click a button to open an instance of Internet Explorer, navigate to the web form, input the data from the cells in the spreadsheet and then load up the reports selected.
Code for the web form
<br>
<body>
</body>
</html>
<head>
<!--include file="../../Connections/SQL.asp" -->
<title>Performance Reporting</title>
<link href="../../CSS/KPI_Style.css" rel="stylesheet" type="text/css">
<link href="../../CSS/KPI_Style.css" rel="stylesheet" type="text/css">
<link href="../CSS/KPI_Style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style45 {color: #990000}
-->
</style>
<script type="text/javascript" language="javascript">
<!--
function makeDisable(){
var y=document.getElementById("store")
var x=document.getElementById("CHNSplits")
if (y.value=='CP11')
{
x.disabled=true
}
}
function makeEnable(){
var x=document.getElementById("CHNSplits")
x.disabled=false
}
-->
</script>
</head>
<body>
<div align="center">
<link href="../CSS/PL_Style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {font-size: 16px}
.style33 {color: #ffffff}
-->
</style>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#001446" class="border9"><div align="left"><img src="80.gif" alt="DSGi" /></div></td>
<td valign="bottom" bgcolor="#001446" class="border16"><div align="right" class="xbig style1 style33"><span class="style2">Store Performance</span> </div></td>
</tr>
</table>
<br>
<br>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: url();
}
.style1 {
color: #d33;
font-size: 18px;
}
.style2 {color: #000000; font-size: 2px; }
.style10 {color: #d33}
.style15 {font-size: 12px}
-->
</style>
<title></title>
</div>
<link href="../../../Testing/KPI/NewKPI/Digital_KPI/stylesheet.css" rel="stylesheet" type="text/css">
<div align="center"><span class="reportname"> Reporting Selection</span></div>
<form name="form1" id="form1" method="post" action="Get_Page_V4.asp">
<input name="store" type="hidden" value="2397" >
<input name="ViewType" type="hidden" value="store" >
<table width="60%" border="1px" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<td colspan="2"><div align="center" class="formnamesmall">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr height="4">
<td></td>
</tr>
<tr height="5">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="6"><div align="center" class="formtextverylarge">Selected Location:</span> 1111</div></td>
</tr>
<tr>
<td><input name="RadioGroup1" type="radio" value="1" checked></td>
<td class="formnamesmall" ><strong>Yesterday</td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr class="formtext">
<td><input type="radio" name="RadioGroup1" value="2"></td>
<td class="formnamesmall" ></td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall"> </td>
<td class="formtext">
<input name="datebox" type="hidden" id="datebox" value="07/10/2018" size="10" maxlength="10"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr>
<td><input type="radio" name="RadioGroup1" value="3"></td>
<td class="formnamesmall" ><strong>Week</td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Week </td>
<td class="formtext">
<input name="week" type="text" id="week" value="24" size="2" maxlength="2"></td>
</tr>
<tr>
<td> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Financial Year </td>
<td class="formtext">
<input name="weekyear" type="text" id="weekyear" value="2019" size="4" maxlength="4"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr class="formtext">
<td><label>
<input type="radio" name="RadioGroup1" value="4">
</label></td>
<td class="formnamesmall" ><strong>Period</td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Period </td>
<td class="formtext">
<input name="period" type="text" id="period" value="6" size="2" maxlength="2"></td>
</tr>
<tr class="formtext">
<td> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Financial Year </td>
<td class="formtext">
<input name="periodyear" type="text" id="periodyear" value="2019" size="4" maxlength="4"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr class="formtext">
<td><input type="radio" name="RadioGroup1" value="6"></td>
<td class="formnamesmall" ><strong>Year </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Financial Year </td>
<td class="formtext">
<input name="YearYear" type="text" id="YearYear" size="4" maxlength="4" value="2019" ></td>
</tr>
<tr><td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
</tr>
<!--
<tr>
<td colspan="4"><div align="center"><span class="formnamesmall style45">Select Report Type</span></div></td>
<td> </td>
<td colspan="2" class="formname" ><strong></td>
</tr>
-->
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<tr>
<!--
<td><div align="center">
<input name="RadioGroup2" type="radio" class="Style10" value="1" >
</div></td>
<td>
<div align="right" class="formnamesmall style45">
<div align="left">Charts </div>
</div></td>
-->
<input name="RadioGroup2" type="hidden" class="Style10" value="6" checked="Checked">
<!--
<td><div align="right" class="formnamesmall">
<div align="left" class="style45">League Tables
</div>
</div></td>
-->
<td class="formnamesmall" colspan="4"> </td>
<td><input type="submit" name="Submit" value="Display Report"></td>
</tr>
</table>
<p> </p>
</div></td>
</tr>
</table>
<input name="page_name" type="hidden" value="Region_Page1_" />
</form>
<br>
<br>
<style type="text/css">
<!--
.style1 {
font-size: 10px;
color: #FFFFFF;
}
-->
</style>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom" bgcolor="#001446"><div align="right" class="xbig style1 style1"> </div></td>
</tr>
</table>
</body>
VBA code
Sub Get_Data()
Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim HWNDSrc As Long
Dim dates As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://INTRANETSITE/Summary_Select.asp"
Do Until .readyState = 4 And Not .Busy
DoEvents
Loop
.document.all.Item("radioGroup1")(3).Checked = True 'Select the 4th checkbox down on the list
.document.forms(0).submit 'Submit the form to generate the result
End With
Pause (2)
With IE
.navigate "http://INTRANETSITE/ReportDetail2.asp?"
Do Until .readyState = 4 And Not .Busy
DoEvents
Loop
End With
End Sub
The code above navigates to the web form and does select the 4th radio button which is for period reports, then submits the form and displays the first page.
How do I interact with the text boxes to also amend which week or period I want to select reports for?
Also, when it tries to navigate to ReportDetail2.asp it returns the following error and then crashes the VBA code.
Method 'Navigate' of object 'IWebBrowser2' failed
The long term goal of this is to navigate through 20+ pages of reports, pulling the data from each table into a tab on the spreadsheet, so if it can't navigate between the reports, even before we get to the code to pull the data, then that's a problem.
Try something like the following. I am showing the different options you might consider so remember to comment out those you don't want to use.
You need to add a reference to Microsoft Internet Controls via VBE > Tools > References or use late bound call of
Dim ie As New InternetExplorer : Set ie = CreateObject("InternetExplorer.Application")
VBA:
Option Explicit
Public Sub MakeSelections()
Dim ie As New InternetExplorer
Const URL As String = "yourURL"
With ie
.Visible = True
.navigate URL
While .Busy Or .readyState < 4: DoEvents: Wend
With .document
.querySelector("[value='1']").Checked = True 'Yesterday. CSS attribute = value selector
.querySelector("[value='3']").Checked = True 'Week
.querySelector("[value='4']").Checked = True 'Period
.querySelector("[value='6']").Checked = True 'Year
.getElementById("week").Value = 6 'week value
.getElementById("weekyear").Value = 2018 'financial year value
.getElementById("period").Value = 6 'period value
.getElementById("periodyear").Value = 2018 'period financial year value
.getElementById("yearyear").Value = 2019 'financial year value
.querySelector("[value='Display Report']").Click 'display report
End With
Stop '<== Delete me later
'.Quit '<== Remember to quit application
End With
End Sub

Toggle radio buttons between to different sets

I would like to toggle selection between two different sets of radio buttons.
The condition that must be met is that if the user checks the button on one set (called in the example l1), it is unchecked in the other set (called in the example m1).
In other questions, it seems that it is only feasible solution is using Java scripts.
Below is the code:
<table border="0" cellpadding="1" cellspacing="1" style="width: 500px;">
<tbody>
<tr>
<td style="width: 300px;"> </td>
<td style="width: 100px; text-align: center;">Least</td>
<td style="width: 100px; text-align: center;">Most</td>
</tr>
<tr>
<td>{{question1}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-1" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="1" /></td>
</tr>
<tr>
<td>{{question2}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-2" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="2" /></td>
</tr>
<tr>
<td>{{question3}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-3" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="3" /></td>
</tr>
<tr>
<td>{{question4}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-4" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="4" /></td>
</tr>
</tbody>

How do I use html decode in my view page?

My engine is Aspx.
I am currently having trouble editing one of my columns(Question Answer) in my table because it has html tags in it. Is there a way I can decode only that specific row/column in the value area?
<form id="updateFreqQuestionsUser" action="<%=Url.Action("SaveFreqQuestionsUser","Prod")%>" method="post">
<table>
<tr>
<td colspan="3" class="tableHeader">Freq Questions User Details <input type ="hidden" value="<%=freqQuestionsUser.freqQuestionsUserId%>" name="freqQuestionsUserId"/> </td>
</tr>
<tr>
<td colspan="2" class="label">Question Description:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionDescription" value="<%=freqQuestionsUser.questionDescription%>" />
</td>
</tr>
<tr>
<td colspan="2" class="label">QuestionAnswer:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionAnswer" value="<%=freqQuestionsUser.questionAnswer%>" />
</td>
</tr>
<tr>
<td colspan="3" class="tableFooter">
<br />
<a id="freqQuestionsUserUpdateButton" href="#" class="regularButton">Save</a>
Cancel
</td>
</tr>
</table>
Yes, you can do this:
<input type="text" maxlength="2000" name="QuestionAnswer"
value="<%=Server.HtmlDecode(freqQuestionsUser.questionAnswer)%>" />
Reference

How to disable all td tag in jsp using css

I have a form that is in jsp at one condition the user click to view the form. When the form is render the information contain in the form should not be editable all the td should be visible but should not be editable.
for example:-
<table width="600" align="center" >
<tr>
<td class="td_left_b" width="30%">Company Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.companyName}" id="companyName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Hotel Name(Display Name):</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.hotelName}" id="hotelName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Country:</td>
<td width="60%" height="25"><input type="text" size="28" value="" id="country"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">City:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.cityName}" id="cityName"/></td></tr>
<tr>
<td class="td_left_b" width="30%">NeighbourhoodName:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.neighbourhoodName}" id="neighbourhoodName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Street Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.streetName}" id="streetName"/></td>
</tr>
</table>
The above information i am putting through spring MODEL ATTRIBUTE in respective td. i dont want to be editable the information.
Thanks.
You cannot disable Tablecolumns. You have to disable evere input in your table.

Resources