I write a ASP.NET Application for creating a signatur and other stuff. And I use the AjaxToolkit with the CalenderExtender. I want if I click on a ImageButton that open the extender and the TextBox get the Data. It works fine but I don't see the ButtonImage :( >.<
Where I can get a Image for my ImageButton and how it works? Here my ASPX Site Code
...
<tr>
<td>Abwesenheit von: </td><td>
<asp:TextBox ID="txtAbwesenheitVon" runat="server" Enabled="false"></asp:TextBox>
<asp:ImageButton ID="imgbtnAbwesenheitVon" runat="server" ToolTip="Abwesenheit von..." PostBackUrl="~/App_Theme/Calender.ico" />
<asp:CalendarExtender ID="AbwesenheitVon" runat="server" TargetControlID="txtAbwesenheitVon"
Format="dd.MM.yyyy" PopupButtonID="imgbtnAbwesenheitVon"></asp:CalendarExtender>
</td>
</tr>
...
My second Question is.
Can I use a Label for the textBox, too?
But I see only this..._->
Replace
PostBackUrl="~/App_Theme/Calender.ico"
with
ImageUrl = "~/App_Theme/Calender.ico"
Image.ImageUrl Property
Use ImageUrl property instead of PostBackUrl
Related
I am working on a web application. The process regarding the problem is that I am fetching users comments from DB using Entity Framework Model. I am using a listview to show Customers Name, Rating and Comments.
The problem is that I am using a Ajax toolkit control called HTMLEditor for storing comments in the DB, so when I have to display the comments, I need the same control ie HTML Editor. Now when I use the following code to create the ITEMTEMPLATE for the listview,
<ItemTemplate>
<tr style="background-color:#EDECB3;color: #000000;">
<td><%# Eval("CustomerName")%></td>
<td> <img src='Styles/Images/ReviewRating<%# Eval("Rating") %>.png' alt="">
<br />
</td>
<td> <cc1:Editor ID="Comments" runat="server" Text="<%#Eval("Comments") %>"/>
</td>
</tr>
</ItemTemplate>
Everything is working except the line
<td> <cc1:Editor ID="Comments" runat="server" Text="<%#Eval("Comments") %>"/>
</td>
It says that the server tag is not well formed. please help.
Updated Error: I added nounicode="true". and the error I encountered is
Could not find any resources appropriate for the specified culture or
the neutral culture. Make sure
"AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly
embedded or linked into assembly "AjaxControlToolkit" at compile time,
or that all the satellite assemblies required are loadable and fully
signed.
you should try
<cc1:Editor ID="Comments" runat="server" Text="<%#Eval('Comments') %>"/>
the text proprty is not the same.
Try below code:
Text='<%#Eval("Comments") %>'
Using the ScriptManager on the page solve the problem.
As far as the problem of displaying HTML text in HTML Editor is concerned, I decided not to use the HTML Editor from Ajax Control Toolkit. Rather I displayed the html text raw on the page using the html decoding utility like this,
<%#Server.HtmlDecode(Eval("Comments").ToString()) %>
"rr_only4you" told that answer is correct, i got the error like use blow one
Text="<%#Eval("Comments") %>"
after that i change that to
Text='<%# Eval("Comments") %>'
this format it will correct,
you use this one
<cc1:Editor ID="Comments" runat="server"><%# Eval("Comments") %></cc1>
I am hoping that someone can help shed some light on this issue I've been struggling over for the last couple of days. I have been using the AJAX Toolkit ModalPopupExtender outside of ListViews perfectly fine, but for some reason I can't seem to wrap my head around why this code is not working inside of a ListView item template.
Basically, what I am trying to achive is: a user is presented with some rows of data via the ListView in which each row displays a LinkButton with the text "Remove". I want the user to be able to click on this link, and a modal dialog box pop up and ask them if they are sure they want to do this. If they click the okay button, it should fire off an event and do the necessary database work and reload the page... if not, cancel the postback request and clear the dialog box.
With the code below, I have successuflly hooked into the link button via the targetid property of the ModalPopupExtender so the dialog does popup. However, the okay button does not fire off the event I've written (I've placed a breakpoint in the codebehind within the event, and it does not get touched). Also, the cancel button does not work as it normally would outside of the listview control.
I must be missing something fairly fundamental here, but I'm at a loss - any help would greatly be appreciated. I'm certainly open to alternative methods if this just isn't viable.
<ItemTemplate>
<tr>
<td align="center">
<asp:Label runat="server" ID="lblUserID" Text='<%# Eval("USERID") %>' Visible="false" />
<asp:LinkButton runat="server" ID="lnkRemoveUser" Text="Remove" />
<asp:Panel ID="removeUserModalPanel" runat="server">
<div class="popup">
<div class="loginTitleBar" id="Div1">
Remove User
</div>
<div class="popupBody">
<p>
Are you sure you want to remove this user?
</p>
</div>
<div class="popupControls">
<asp:Button id="btnRemoveUserOkay" runat="server" type="button" Text="Remove User"
onclick="btnRemoveUserOkay_Click" />
<input id="btnRemoveUserCancel" type="button" value="Cancel" />
</div>
</div>
</asp:Panel>
<asp:ModalPopupExtender
ID="removeUserModalPopupExtender"
runat="server"
BackgroundCssClass="ModalPopupBG"
CancelControlID="btnRemoveUserCancel"
TargetControlID="lnkRemoveUser"
PopupControlID="removeUserModalPanel"
drag="false" >
</asp:ModalPopupExtender>
</td>
<td>
<asp:LinkButton ID="lnkUserName" runat="server" Text='<%# Eval("USERNAME") %>' />
</td>
<td>
<asp:Label ID="lblFirstName" runat="server" Text='<%# Eval("FIRSTNAME") %>' />
</td>
<td>
<asp:Label ID="lblLastName" runat="server" Text='<%# Eval("LASTNAME") %>' />
</td>
<td>
<asp:Label ID="lblEmailAddress" runat="server" Text='<%# Eval("EMAILADDRESS") %>' />
</td>
</tr>
</ItemTemplate>
Finally I can make this works. It's a little tricky though. Here are the steps:
Move the panel, the button close and the modalpopupextender outside the listview
Create a HiddenField or whatever control and associate this with the TargetControlID of the ModalPopupExtender control.
In the button on the ListView handle the Click event, and in the code behind call directly to the ModalPopupExtender.Show() method, and voilá.
It is a little dirty indeed, but the ModalPopupExtender seems to override the click event of the listview button when it's associated with the control.
Seems like a problem with having the ModalPopupExtender on a databound repeated row.
Stupid idea #1 : Could you try hiding lnkRemoveUser until the row is selected - then, in the SelectionChanged event, highlight the row, display the button, and hook the button to the ModalPopupExtender?
Stupid idea #2 : Have a hidden button outside the ListView, and hook up your ModalPopupExtender to that. Then have your linkbutton call that button's onclick ().
This is not just another FileUpload + UpdatePanel question.
I have, as stated in the many similar posts, an UpdatePanel and a FileUpload control on my form. I also have a PostBackTrigger set up for my upload button.
It works. The catch is it never does work on first time click. That is:
I click on browse, select my file, press upload. Nothing happens (fupld.HasFile = false);
I click on browse again, select any file (the same or another), press upload and it works fine.
<asp:UpdatePanel ID="upGeneral" runat="server" >
<ContentTemplate>
...
<table id="tabPage10" runat="server" visible="false" width="100%" >
<tr>
...
<td>
<asp:FileUpload ID="fupld" runat="server" Width="80%" />
<asp:ImageButton ID="ibtnUpld" runat="server" onclick="ibtnUpld_Click" />
<td>
...
<tr>
...
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="ibtnUpld" />
</Triggers>
</asp:UpdatePanel>
I've looked around for answers, but this is some really weird behaviour. No luck so far.
Any ideas?
Thanks
Well, the FileUpload control is designed to be used only in postback scenarios and not in asynchronous postback scenarios during partial-page rendering.
http://msdn.microsoft.com/en-us/ysf0192b#using_the_FileUpload_Control_with_the_UpdatePanel_control
You could use the AsyncFileUpload control instead from the AjaxControlToolkit.
<asp:AsyncFileUpload runat="server" ID="asyncFileUpload" Width="400px" ThrobberID="imageThrobber"
OnClientUploadStarted="uploadStarted" OnClientUploadError="uploadError"
ClientIDMode="AutoID" PersistFile="true" PersistedStoreType="Session" />
code behind:
if (asyncFileUpload.HasFile)
{
string fullPath = GetPath(asyncFileUpload.FileName);
asyncFileUpload.SaveAs(fullPath);
}
I've never had any problems with it.
With Post back triggers I had to use the below line of code in code behind:
Page.Form.Enctype = "multipart/form-data";
And this works perfectly fine.
Thanks to the solution in the link - (http://patelshailesh.com/index.php/file-upload-control-fails-first-time-then-works-on-subsequent-submits).
Change
Visible ="false"
to
style="display:none"
and change it from code behind.
If you set Visible="false, control is not actually rendered as HTML. To rendered it as HTML, use style = "display:none" instead of Visible="false"
Hi say of have a table of cars in my SQL database. That table has a column for the car make and a column called picture of type:
Picture(image, null)
I'm then displaying my cars in a repeater and so it might look like this:
<asp:Repeater id="carsRepeater" runat="server" DataSourceID="CarsDataSource>
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label id="carMakeLabel" runat="Server" Text='<%# Eval("Make") %>' />
</td>
<td>
Some how display a clickable image here
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</Footer>
</asp:Repeater>
What I'm wanting is in column two to get the picture of the car to display and make it so you can click on that picture and it will run a method in the code behind. Also I have this requirement where the picture click method mustn't require javascript to run.
Can someone please give me an idea of how I would go about this?
I'm currently thinking about putting the image somehow in a link but I'm not sure how to display the image. Maybe the asp:Image but that requires an ImageUrl.
Try image button, it displays an image, doesn't require javascript and you can run a method on click event from code behind
Write an HTTPHandler (say CarImage.ashx) and in that handler, given ID of the image return the binary data with ContentType of image/gif (or whatever). Render an image tag in the datagrid with src as CarImage.ashx?ImageID=xxxxx. The process is described many place including this one.
I need to access a label control in a listview when I've clicked a button (that is on the same row)...
Does anyone know how to do this please? :(
See below for more of an insight...
ASPX Page:
<asp:ListView ID="ListView1" runat="server" DataSourceID="DataSource">
<LayoutTemplate>//Etc </LayoutTemplate>
<ItemTemplate>
<asp:Label ID="lblDone" runat="server" Visible="false">Your vote has been counted</asp:Label>
<asp:Button ID="voteButton" runat="server" Text="Vote" CommandArgument='<%#Eval("id") %>' OnClick="voteOnThis" />
</ItemTemplate>
Code Behind:
protected void voteOnThis(object sender, EventArgs e)
{
Button myButton = (Button)sender;
Voting.vote(int.Parse(myButton.CommandArgument));
// Here i would like to access the 'label' lblDone and make this Visible
}
In this simple case, I should consider using Javascript (JQuery)
<asp:ListView ID="ListView1" runat="server" DataSourceID="DataSource">
<LayoutTemplate>//Etc </LayoutTemplate>
<ItemTemplate>
<asp:Label ID="lblDone" runat="server" style="visibility:hidden">Your vote has been counted</asp:Label>
<asp:Button OnClientClick="showLblDone()" ID="voteButton" runat="server" Text="Vote" CommandArgument='<%#Eval("id") %>' OnClick="voteOnThis" />
</ItemTemplate>
now, define inside a script tag the showLblDone function:
<script>
function showLblDone (){
$(this).siblings('span').show();}
</script>
You can also call this function with a parameter if you want to show/hide on every click, or you can use .toggle() instead of .show().
In this case you must add a div (or a Panel) inside the ItemTemplate.
You need to hook into the listview row bind and add the information you want to have when clicked. Using this, you can add an attribute to the button that you read back on click, for example...
If you posted some actual code, I could probably help some more.