code-behind

How to access a selected Boundfield value from a GridView in code-behind

孤人 提交于 2019-12-07 09:33:42
问题 I have seen similar questions but none of the answers helped me to workout this problem. I have GridView with a ReadOnly field as follow. GridView: <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="projectID" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." PageSize="5" OnRowUpdating="GridView1_RowUpdating"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"/> <asp:BoundField

Cannot set image source in code behind

我与影子孤独终老i 提交于 2019-12-07 07:53:09
问题 There are numerous questions and answers regarding setting image source in code behind, such as this Setting WPF image source in code. I have followed all these steps and yet not able to set an image. I code in WPF C# in VS2010. I have all my image files under a folder named " Images " and all the image files are set to Copy always . And Build Action is set to Resource , as instructed from documentation. My code is as follow. I set a dog.png in XAML and change it to cat.png in code behind. //

How to access span id in code behind

点点圈 提交于 2019-12-07 05:04:43
问题 I have an asp website with the following control: <span id="expTrainingShow" class="clsLink" style="margin-left: 20px;" onclick="GridChanger();"> + Show Expired Continuing Education</span> I want to hide this based on a condition set in the code behind. Can I access a span id like that? (the website is built using visual basic) 回答1: You can use a Label instead of a html-span (which is also rendered as span) or you could add runat="server" . <span id="expTrainingShow" runat="server" class=

ASP.Net 3.5/4.0 CodeBehind or CodeFile?

南笙酒味 提交于 2019-12-07 04:16:55
问题 I read through the previous post: CodeFile vs CodeBehind, but I'm still confused on which I should use. It sounds like CodeFile is the newer option that should be used, yet VS2010 generates CodeBehind when creating a new Web Form. 回答1: It depends on your template, check out web site vs. web application. I tend to prefer web application for several reasons, but that is up to you. If you see code-behind, you probably have selected that template. 来源: https://stackoverflow.com/questions/2585463

Prevent Form Resubmission in ASP.Net (without redirecting to myself)

二次信任 提交于 2019-12-07 03:06:25
问题 I have a master page with a Form element ( <form runat="server"> ), a content page with a Button element ( <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Sync" /> ), and a Code Behind page that contains the Button1_Click function. The user comes to the page and clicks the button. The Code Behind code executes (on the server) in which it updates some tables in a database. The last thing the Code Behind code does is to set the InnerHTML of a Span element on the content

Access control in style from code [duplicate]

感情迁移 提交于 2019-12-06 12:05:49
问题 This question already has answers here : How do I access an element of a control template from within code-behind (2 answers) Closed 6 years ago . If I have a style that defines a control template, and in this I have a control, let's say a button, is there any way to access the button from code behind of the styled control? Thank you guys! =) 回答1: Say you have a style defined as follows <Style x:Key="myStyle" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value>

How do I handle click events on multiple similar buttons in WPF?

怎甘沉沦 提交于 2019-12-06 11:50:01
I'm a C# beginner and am trying to implement a numeric pad in WPF. It consists of 10 similar buttons: <Button Content="0" Name="button0" Click="anyButtonClicked" /> <Button Content="1" Name="button1" Click="anyButtonClicked" /> <Button Content="2" Name="button2" Click="anyButtonClicked" /> ... <Button Content="9" Name="button9" Click="anyButtonClicked" /> What is the best practise to handle all those buttons? Do I build a function in the code behind for each one (Which would be mostly boring and repeating myself), or do I build one to handle any button clicked? In the second case, how do I

How to write a method to open an image in C# that will use the default image viewer on a mobile device…?

我与影子孤独终老i 提交于 2019-12-06 11:10:55
Apologizes for the long title! I'm fairly new to C# (probably only 2-3 months of concrete knowledge) that I learned in College... I've been experimenting with Xamarin Forms XAML and I was wondering how I would write a method in the code-behind that opens the tapped image to be opened in the default image viewer for Android or iOS. I say Android or iOS because I'm doing cross-platform Xamarin Forms PCL. Thanks :) Happy Holidays and a Great New Year :D! Try following code : PCL interface : namespace MyApp.Common.Interfaces { public interface IDataViewer { void showPhoto(string AttachmentName,

Response.Redirect to Class that inherits from UI.Page?

妖精的绣舞 提交于 2019-12-06 08:18:45
everyone, thank for your time. Well this my problem (well it's not a probleam at all), it is possible to have a class that inherits from ui.page and then instance an object of that class and do a redirect to it ? Something like this: Public sub myMethod() Dim myPage as new myClassThatInheritsFromUIPage() Response.redirect(myPage) 'Here is one of my "no-idea" line end sub I do this in my webForm (and that what I want to do in a class that inherits from ui.page): Response.BufferOutput = True Response.ClearContent() Response.ClearHeaders() ostream=crReportDocument.ExportToStream(CrystalDecisions

retrieve value from javascript function in codebehind

拟墨画扇 提交于 2019-12-06 08:08:14
How can I retrieve value from javascript function in codebehind, on page load .. javascript function like : <script type="text/javascript"> function isIFrame() { var isInIFrame = (top.location != self.location); if (isInIFrame) { return "inside"; } else { return "outside"; } } </script> and code behind like : protected void Page_Load(object sender, EventArgs e) { string resutOfExecuteJavaScript = ""; // resutOfExecuteJavaScript = isIFrame(); // from javascript if (resutOfExecuteJavaScript == "inside") { // do something } else { // do something } } thank you. You cannot directly call a client