Find control of repeater nested in datalist on repeater item command - repeater

In my code repeater is nested in datalistdatalist contains checkboxes and radiobutton
i want to do database operation on checkchanged of checkboxes,so i had written this operation on repeater itemcomand. Here I am not able to find control of repeater.so please guide me how to find control of repeater.
My design is like this:
<asp:DataList ID="DatalistQues" runat="server" DataKeyField="QuestionID" OnSelectedIndexChanged="DataListText_SelectedIndexChanged"
Width="100%" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<table width="100%">
<tr>
<td style="width: 13%">
<asp:LinkButton ID="LinkButton6" runat="server" CommandName="Select" CssClass="ppppp">
<asp:Image ID="Image1" runat="server" ImageUrl='<% #Eval("Image")%>' Height="60px"
Width="65px" />
</asp:LinkButton>
</td>
<td style="width: 87%">
<asp:LinkButton ID="LinkButton7" runat="server" CommandName="Select" CssClass="ppppp">
<asp:Label ID="Label3" runat="server" Text='<% #Eval("name")%>'></asp:Label>
</asp:LinkButton>
</td>
</tr>
<tr>
<td style="width: 13%">
</td>
<td style="width: 87%; white-space: pre-line">
<asp:Label ID="TextBox2" runat="server" Text='<% #Eval("Question")%>'></asp:Label>
</td>
</tr>
<tr>
<td style="width: 13%">
</td>
<td style="width: 87%">
<script type="text/javascript" language="javascript">
function fnCheckUnCheck(objId) {
var grd = document.getElementById("TabContainer1_TabPanel2_DatalistQues");
alert(grd);
//Collect A
var rdoArray = grd.getElementsByTagName("input");
alert(rdoArray);
for (i = 0; i <= rdoArray.length - 1; i++) {
if (rdoArray[i].type == 'radio') {
if (rdoArray[i].id != objId) {
rdoArray[i].checked = false;
}
}
}
}
</script>
<asp:Repeater ID="RepeaterQues" runat="server" OnItemCommand="Repeater1_ItemCommand">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<table style="border: none">
<tr>
<td style="width: 100px">
<asp:LinkButton ID="LinkButton23" runat="server" CommandName="radiob">
<asp:RadioButton ID="RadioButton1" runat="server" onclick="fnCheckUnCheck(this.id);" /></asp:LinkButton><asp:LinkButton
ID="LinkButton24" runat="server" CommandName="checkb">
<asp:CheckBox ID="CheckBox1" runat="server" Text='<%#Eval("QOption") %>' /></asp:LinkButton>
</td>
<td style="width: 100px">
<asp:Label ID="empname" Text='<%#Eval("QOption") %>' runat="server"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

Try this
((Repeater)e.Item.Parent).ID // this gives the ID as specified on the aspx page
If you need Unique ID, you have to use this
((Repeater)e.Item.Parent).ClientID

On Item command of Repeater you will have to first find the naming container of sender
it will return you datalist item.
then in returned list item you will have to find the repeater of that particular data list itme
once you will find the repeater you can easily find the controls of the item of repeater

Related

Thymeleaf , Map object which has value as List of districts .?

Suppose we have a Map object which has State as it's Key and List of districts in a State as it's Value. This how I am iterating over this kind of Map object.but each district is NOT getting printed on a new row. Can someone help ???
<div th:if="${not #lists.isEmpty(stateToDistrictMap)}">
<table>
<tr><td>State</td><td>Districts</td></tr>
<th:block th:each="state : ${stateToDistrictMap}">
<tr>
<td th:text="${state.key}">State</td>
<th:block th:each="district : ${state.value}">
<td th:text="${district.name}">District</td>
<td th:text="${district.code}">District</td>
<td th:text="${district.erstyear}">District</td>
<td th:text="${district.info}">District</td>
</th:block>
</tr>
</th:block>
</table>
</div>
Can someone help ???
You probably want something like:
<div th:if="${not #lists.isEmpty(stateToDistrictMap)}">
<table>
<tr>
<td>State</td>
<td>Districts</td>
</tr>
<th:block th:each="state: ${stateToDistrictMap}">
<tr th:each="district, i: ${state.value}">
<td th:text="${i.first ? state.key : ' '}" />
<td th:text="${district.name}" />
<td th:text="${district.code}" />
<td th:text="${district.erstyear}" />
<td th:text="${district.info}" />
</tr>
</th:block>
</table>
</div>

uploading a file with python

I'm pretty new to programming and i'm trying to write a program that will upload a file to a website. I really don't know what I'm doing wrong. The file isn't getting uploaded. I think my issue is to do with the multipart form data but i wouldn't be surprised if i'm wrong.
import requests, os, sys
url = "myURL"
uploadFile = {'ILWinterConditions.kmz': open('C:\\Users\\JOC-001\\Documents\\GIS\\IDOT\\ILWinterConditions.kmz', 'rb')}
payload = {
'fname': 'myfname',
'lname': 'mylname',
'org': 'myorg',
'phone': 'myphone',
'email': 'myemail',
'datadescrip': 'mydatadesc',
'uploadedfile': 'C:\\Users\\JOC-001\\Documents\\GIS\\IDOT\\ILWinterConditions.kmz'
}
r = requests.post(url, verify = False, auth=('myUsername','mypassword'), files=uploadFile, data=payload)
print r.content
Below is the response I'm getting from print and the file is not being uploaded
<head>
<title>*I have censored this*</title>
<link rel="stylesheet" href="styles.css"/>
</head>
<body>
<script type="text/javascript">
// Add other extensions here if we want to allow other files to be
// uploaded. Check is not case-sensitive. Will also be checked on
// the server.
var allowedExtensions = [ "kml", "kmz", "jpg", "png", "csv" ];
var maxSize = 12 * 1024*1024;
var errorMessage = "Only .csv, .kml, .kmz, .jpg, or .png files up to 12MB are accepted!";
// Checks that the file meets our criteria. This is just for user
// convenience-- to catch problems before they attempt to do the
// upload. The file will be checked again on the server too.
function FileIsOkay() {
var fileInput = document.getElementById('uploadedFile');
// First check the file's extension
var fileName = fileInput.value;
var fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
var extensionOK = false;
for (var i=0; i<allowedExtensions.length; ++i) {
if (fileExtension == allowedExtensions[i].toLowerCase()) {
extensionOK = true;
break;
}
}
if (! extensionOK) {
alert(errorMessage);
return false;
}
// Now check the file's size.
// Doesn't work in IE, but that's okay... it'll get checked on
// the server any way.
if (fileInput.files) {
var file = fileInput.files[0];
if (file) {
if (file.size > maxSize) {
alert(errorMessage);
return false;
}
}
}
return true;
}
</script>
<div class="title">
<img src="webdavtitle.png"/>
</div>
<form method="POST" action="uploader.php" enctype="multipart/form-data" onsubmit="return FileIsOkay();" class="fileForm">
<table class="detailsTable">
<tr>
<td class="inputLabel">First Name:</td>
<td class="inputField"><input type="text" name="fname" size="40"></td>
</tr>
<tr>
<td class="inputLabel">Last Name:</td>
<td class="inputField"><input type="text" name="lname" size="40"></td>
</tr>
<tr>
<td class="inputLabel">Organization/Agency:</td>
<td class="inputField"><input type="text" name="org" size="40"></td>
</tr>
<tr>
<td class="inputLabel">Phone (DSN or Com):</td>
<td class="inputField"><input type="text" name="phone" size="40"></td>
</tr>
<tr>
<td class="inputLabel">Email:</td>
<td class="inputField"><input type="text" name="email" size="40"></td>
</tr>
<tr>
<td class="inputLabel">Data Description:</td>
<td class="inputField"><input type="text" name="datadescrip" size="40"></td>
</tr>
<tr>
<td class="inputLabel">
Choose a .kml, .kmz, .jpg,<br/>
or .png file to upload:
</td>
<td class="inputField">
<input id="uploadedFile" name="uploadedfile" size="40" type="file"/>
</td>
</tr>
<tr>
<td></td>
<td class="inputField"><input type="submit" value="Upload File"></input></td>
</tr>
</table>
</form>
<div class="footer">
<img border="0" src="horiz_grey_line.gif">
</div>
<div class="footer">
<img border="0" src="contacthelp.png">
</div>
<div class="footer">
<img border="0" src="nc_address.gif">
<img border="0" src="nc_webpolicy.gif">
</div>
</body>
I figured out the issue with this code. It should have been
uploadFile = {'uploadedfile': open('C:\\Users\\JOC-001\\Documents\\GIS\\IDOT\\ILWinterConditions.kmz', 'rb')}
to fit the form data. and 'payload' did not need the
'uploadedfile': 'C:\\Users\\JOC-001\\Documents\\GIS\\IDOT\\ILWinterConditions.kmz'

Nokogiri parsing with xpath returns empty string

I have the following HTML:
<div>
<table>
<tr>
<td>
<div class="w135">
<div style="float: left; padding-right: 10px;" class="imageThumbnail playerDiv">
<a href="/sport/tennis/2014/10/djokovic-through-wozniacki-out-china-open-2014101114115427766.html" id="ctl00_ctl00_DataList1_ctl00_Thumbnail1_lnkImage10" target="_parent">
<img src="/mritems/imagecache/89/135/mritems/images/2014/10/1/2014101114447491734_20.jpg" id="ctl00_ctl00_DataList1_ctl00_Thumbnail1_imgSmall10" border="0" class="imageThumbnail">
</a>
</div>
</div>
</td>
</tr>
</table>
</div>
When i attempt the rake, i get the error:
NoMethodError: undefined method `at_css' for ["id","ctl00_cphBody_ctl01_DataList1_ctl00_Thumbnail1_Layout17"]:Array
This is the code:
#request = HTTParty.get(url)
#html = Nokogiri::HTML(#request.body)
#html.css(".w135")[0].map do |item|
url = item.at_css("div.playerDiv a")
puts url.inspect
end
I'm really not sure what the issue is and have been trying to fix this for a while. The error occurs on this line url = item.at_css("div.playerDiv a")
Any suggestion is appreciated!
Thanks
I'd do it using something like:
require 'nokogiri'
doc = Nokogiri::HTML(<<EOT)
<div>
<table>
<tr>
<td>
<div class="w135">
<div style="float: left; padding-right: 10px;" class="imageThumbnail playerDiv">
<a href="/sport/tennis/2014/10/djokovic-through-wozniacki-out-china-open-2014101114115427766.html" id="ctl00_ctl00_DataList1_ctl00_Thumbnail1_lnkImage10" target="_parent">
<img src="/mritems/imagecache/89/135/mritems/images/2014/10/1/2014101114447491734_20.jpg" id="ctl00_ctl00_DataList1_ctl00_Thumbnail1_imgSmall10" border="0" class="imageThumbnail">
</a>
</div>
</div>
</td>
</tr>
</table>
</div>
EOT
puts doc.search('.w135 div.playerDiv a').map(&:inspect)
Which outputs:
# >> #<Nokogiri::XML::Element:0x3ff0918b132c name="a" attributes=[#<Nokogiri::XML::Attr:0x3ff0918b1250 name="href" value="/sport/tennis/2014/10/djokovic-through-wozniacki-out-china-open-2014101114115427766.html">, #<Nokogiri::XML::Attr:0x3ff0918b123c name="id" value="ctl00_ctl00_DataList1_ctl00_Thumbnail1_lnkImage10">, #<Nokogiri::XML::Attr:0x3ff0918b1228 name="target" value="_parent">] children=[#<Nokogiri::XML::Text:0x3ff0918a5b6c "\n ">, #<Nokogiri::XML::Element:0x3ff0918a5360 name="img" attributes=[#<Nokogiri::XML::Attr:0x3ff0918a4d20 name="src" value="/mritems/imagecache/89/135/mritems/images/2014/10/1/2014101114447491734_20.jpg">, #<Nokogiri::XML::Attr:0x3ff0918a4cbc name="id" value="ctl00_ctl00_DataList1_ctl00_Thumbnail1_imgSmall10">, #<Nokogiri::XML::Attr:0x3ff0918a4b90 name="border" value="0">, #<Nokogiri::XML::Attr:0x3ff0918a4a28 name="class" value="imageThumbnail">]>, #<Nokogiri::XML::Text:0x3ff091871920 "\n ">]>
If you're trying to access the "href" parameter, instead of using inspect, use:
puts doc.search('.w135 div.playerDiv a').map{ |n| n['href'] }
# >> /sport/tennis/2014/10/djokovic-through-wozniacki-out-china-open-2014101114115427766.html

Emberjs CollectionView array in an array

Hi I would like to know if it was possible to use a more complex array for the collectionView.
Because for now I'm only using it like this :
App.GroupList = Ember.ArrayController.create({
content: ['A','B','C','D'],
})
App.GroupListView = Ember.CollectionView.extend({
tagName: 'tbody',
contentBinding: "App.GroupList"
})
And display them like this :
<table class="table-history">
{{#collection App.GroupListView}}
<td class="col-left">
{{view.content}}
</td>
<td>
<span class="col-number-contact">0</td>
</td>
<td>
<div class="ph-img"></div>
</td>
<td>
<div class="ed-img"></div>
</td>
{{/collection}}
</table>
So far, so good, its working well, but I would like to add more information inside the content like this :
content: [
['A','1'],
['B','2'],
['C','3'],
]
And display the number in a second <td> tad (the one with the 0 inside).
But its not working.. and I wouldn't even know how to display them in my template.
Someone already managed to passe a complex collection content ?
You can use an array of objects instead like this:
App.GroupList = Ember.ArrayController.create({
content: [{'id':1,val:'A'},{'id':2,val:'B'},{'id':3,val:'C'},{'id':4,val:'D'}];
});
Then in your template, you can access it like this:
<table class="table-history">
{{#collection App.GroupListView}}
<td class="col-left">
{{view.content.val}}
</td>
<td>
<span class="col-number-contact">{{view.content.id}}</td>
</td>
<td>
<div class="ph-img"></div>
</td>
<td>
<div class="ed-img"></div>
</td>
{{/collection}}
</table>

JQuery - Problem with selectors (siblings, parents...)

I got a coldfusion query where the result is grouped on country names. With a click on this one, I try to open or close the list under the country. But i cannot work correctly with this siblings and this parents. The result is, if i click on a country name, the fourth one, for example, it close all childrens, and the three country name which are before too.
Can someone help me to choose the right selectors ?
Thank you in advance ,
Michel
The code:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
var toggleMinus = '<cfoutput>#variables.strWebAddress#</cfoutput>/images/bullet_toggle_minus.png';
var togglePlus = '<cfoutput>#variables.strWebAddress#</cfoutput>/images/bullet_toggle_plus.png';
var $subHead = $('table#categorylist tbody th:first-child');
$subHead.prepend('<img src="' +toggleMinus+ '" alt="collapse this section" /> ');
$('img', $subHead).addClass('clickable').click(function(){
var toggleSrc = $(this).attr('src');
if(toggleSrc == toggleMinus){
$(this).attr('src',togglePlus).parents('.country').siblings().fadeOut('fast');
}else{
$(this).attr('src',toggleMinus).parents('.country').siblings().fadeIn('fast');
}
});
});
</script>
<table width="95%" border="0" cellspacing="2" cellpadding="2" align="center id="categorylist">
<thead>
<tr>
<th class="text3" width="15%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTOR_CODENUMBER">
</th>
<th class="text3" width="15%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTOR_CODE">
</th>
<th class="text3" width="55%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTOR_NAME">
</th>
<th class="text3" width="15%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTIVE">
</th>
</tr>
</thead>
<tbody id="content">
<cfoutput query="qryCategoryUrl" group="country_name" groupcasesensitive="false">
<tr class="country">
<th style="font-weight:bold; text-align:left;" colspan="4">#country_name#</th>
</tr>
<cfoutput>
<tr>
<td valign="top" class="text3">#Replace(ACTOR_CODENUMBER, Chr(13) & Chr(10), "<br>", "ALL")# </td>
<td valign="top" class="text3">#Replace(ACTOR_CODE, Chr(13) & Chr(10), "<br>", "ALL")# </td>
<td valign="top" class="text3">#Replace(ACTOR_NAME, Chr(13) & Chr(10), "<br>", "ALL")# </td>
<td valign="top" class="text3"><cfmodule template="../custom_tags//get_message.cfm" keyName="#ACTIVE_display(qryCategoryUrl.ACTIVE)#"></td>
</tr>
</cfoutput>
</cfoutput>
</tbody>
</table>
Instead of:
.parents('.country').siblings().fadeOut('fast');
Try this:
.closest('.country').nextUntil('.country').fadeOut('fast');
And of course, apply the same change to the .fadeIn(). You might also look into .fadeToggle()docs.
Here's a (reduced) example: http://jsfiddle.net/redler/5sqJz/. While it doesn't affect the example, presumably you would be setting the initial state of those detail rows as hidden.
woah all that cfmodule usage, cfmodule can be a memory hog.
Although what I always recommend is that people try their pages in whatever browser, and use the SelectorGadget bookmarklet at http://www.selectorgadget.com/
This makes it easier to test and check the correct selector, for your app needs.