Search Results

Search found 4334 results on 174 pages for 'sender'.

Page 160/174 | < Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >

  • ASP.NET Repeater and DataBinder.Eval

    - by Fernando
    I've got a <asp:Repeater> in my webpage, which is bound to a programatically created dataset. The purpose of this repeater is to create an index from A-Z, which, when clicked, refreshes the information on the page. The repeater has a link button like so: <asp:LinkButton ID="indexLetter" Text='<%#DataBinder.Eval(Container.DataItem,"letter")%>' runat="server" CssClass='<%#DataBinder.Eval(Container.DataItem, "cssclass")%>' Enabled='<%#DataBinder.Eval(Container.DataItem,"enabled")%>'></asp:LinkButton> The dataset is created the following way: protected DataSet getIndex(String index) { DataSet ds = new DataSet(); ds.Tables.Add("index"); ds.Tables["index"].Columns.Add("letter"); ds.Tables["index"].Columns.Add("cssclass"); ds.Tables["index"].Columns.Add("enabled"); char alphaStart = Char.Parse("A"); char alphaEnd = Char.Parse("Z"); for (char i = alphaStart; i <= alphaEnd; i++) { String cssclass="", enabled="true"; if (index == i.ToString()) { cssclass = "selected"; enabled = "false"; } ds.Tables["index"].Rows.Add(new Object[3] {i.ToString(),cssclass,enabled }); } return ds; } However, when I run the page, a "Specified cast is not valid exception" is thrown in Text='<%#DataBinder.Eval(Container.DataItem,"letter")'. I have no idea why, I have tried manually casting to String with (String), I've tried a ToString() method, I've tried everything. Also, if in the debugger I add a watch for DataBinder.Eval(Container.DataItem,"letter"), the value it returns is "A", which according to me, should be fine for the Text Property. EDIT: Here is the exception: System.InvalidCastException was unhandled by user code Message="Specified cast is not valid." Source="App_Web_cmu9mtyc" StackTrace: at ASP.savecondition_aspx._DataBinding_control7(Object sender, EventArgs e) in e:\Documents and Settings\Fernando\My Documents\Visual Studio 2008\Projects\mediTrack\mediTrack\saveCondition.aspx:line 45 at System.Web.UI.Control.OnDataBinding(EventArgs e) at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at System.Web.UI.Control.DataBind() at System.Web.UI.Control.DataBindChildren() InnerException: Any advice will be greatly appreciated, thank you EDIT 2: Fixed! The problem was not in the Text or CSS tags, but in the Enabled tag, I had to cast it to a Boolean value. The problem was that the exception was signaled at the Text tag, I don't know why

    Read the article

  • WebServices does not interact with App

    - by daemonfire300
    I got a Silverlight App with-in a Web Project Web Silverlight The web contains a service: [WebService(Namespace = "svChat")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. //[System.Web.Script.Services.ScriptService] public class GetIPService : System.Web.Services.WebService { public GetIPService () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string GetIp() { return HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; } } And I got a class in my Silverlight App using the Service: public class Client { private string ip; private string created; #region Properties public string Ip { get { return ip; } set { ip = value; } } public string Created { get { return created; } set { created = value; } } #endregion public Client() { } public void SetIp() { ServiceReference1.GetIPServiceSoapClient scIpClient = new svChat.ServiceReference1.GetIPServiceSoapClient(); scIpClient.GetIpCompleted += new EventHandler<svChat.ServiceReference1.GetIpCompletedEventArgs>(IpService_Completed); scIpClient.GetIpAsync(); } private void IpService_Completed(object sender, ServiceReference1.GetIpCompletedEventArgs e) { this.ip = e.Result; } } After Client is created, SetIp() is called, and Client.Ip is added to a text box. Nothing happens. Ip = null. Service itselfs works, tested it. Getting Ip by the above code works. Gettings Ip via service through Silverlight App does not work. <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="GetIPServiceSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:2090/svChat.Web/GetIPService.asmx" binding="basicHttpBinding" bindingConfiguration="GetIPServiceSoap" contract="ServiceReference1.GetIPServiceSoap" name="GetIPServiceSoap" /> </client> </system.serviceModel> </configuration> Any ideas? regards,

    Read the article

  • Problem creating gui from xml -> Strange CPButton behaviour

    - by Superpro
    Hallo, I'm new to objective-j and cappuccino and just have tried to create a small application, that creates the gui dynamically from a xml file. Unfortunately it works only partially. It seems that the button regions are disorder. This means, that the buttons also response if I click besides the button.... Please help me. I dont get it.. - (void)applicationDidFinishLaunching:(CPNotification)aNotification { mControlList = [CPArray alloc]; theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], contentView = [theWindow contentView]; [contentView setFrame:[[contentView superview] bounds]]; [contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; // Loadxmlfile var xhttp; if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest() } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP") } xhttp.open("GET","test.xml",false); xhttp.send(""); xmlDoc = xhttp.responseXML; //Get controls nodeand iterate through all controls var node = xmlDoc.getElementsByTagName("controls")[0]; for (var i=0; i<node.childNodes.length; i++) { if(node.childNodes[i].nodeName=="button"){ var item = node.childNodes[i]; var name = item.attributes["name"].nodeValue; var text = item.getElementsByTagName("text") [0].childNodes[0].nodeValue; var x= item.getElementsByTagName("rect") [0].attributes["x"].nodeValue; var y= item.getElementsByTagName("rect") [0].attributes["y"].nodeValue; var width= item.getElementsByTagName("rect") [0].attributes["width"].nodeValue; var height= item.getElementsByTagName("rect") [0].attributes["height"].nodeValue; var b = [[Button alloc] InitWithParent:contentView Text:text X:x Y:y Width:width Height:height]; [mControlList addObject:b]; } } [theWindow orderFront:self]; } @implementation Button : CPObject { CPButton _button; } - (Button)InitWithParent:(CPView)contentView Text:(CPString)text X: (int)x Y:(int)y Width:(int)width Height:(int)height { _button = [[CPButton alloc] initWithFrame: CGRectMake(x,y,width,height)]; [_button setTitle:text]; [_button setTarget:self]; [_button setAction:@selector(cmdNext_onClick:)]; [contentView addSubview:_button]; return self; } - (void)cmdNext_onClick:(id)sender { } @end

    Read the article

  • WPF: How to properly override the methods when creating custom control

    - by EV
    Hi, I am creating a custom control Toolbox that is derived from ItemsControl. This toolbox is supposed to be filled with icons coming from the database. The definition looks like this: public class Toolbox : ItemsControl { protected override DependencyObject GetContainerForItemOverride() { return new ToolboxItem(); } protected override bool IsItemItsOwnContainerOverride(object item) { return (item is ToolboxItem); } } Toolboxitem is derived from ContentControl. public class ToolboxItem : ContentControl { static ToolboxItem() { FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(ToolboxItem), new FrameworkPropertyMetadata(typeof(ToolboxItem))); } } Since the number of icons stored in a database is not known I want to use the data template: <DataTemplate x:Key="ToolBoxTemplate"> <StackPanel> <Image Source="{Binding Path=url}" /> </StackPanel> </DataTemplate> Then I want the Toolbox to use the template. <Toolbox x:Name="NewLibrary" ItemsSource="{Binding}" ItemTemplate="ToolBoxtemplate"> </Toolbox> I'm using ADO.NET entity framework to connect to a database. The code behind: SystemicsAnalystDBEntities db = new SystemicsAnalystDBEntities(); private void Window_Loaded(object sender, RoutedEventArgs e) { NewLibrary.ItemsSource = from c in db.Components select c; } However, there is a problem. When the code is executed, it displays the object from the database (as the ItemSource property is set to the object from the database) and not the images. It does not use the template. When I use the static images source it works in the right way I found out that I need to override the PrepareContainerForItemOverride method.But I don't know how to add the template to it. Thanks a lot for any comments. Additional Information Here is the ControlTemplate for ToolboxItem: <ControlTemplate TargetType="{x:Type s:ToolboxItem}"> <Grid> <Rectangle Name="Border" StrokeThickness="1" StrokeDashArray="2" Fill="Transparent" SnapsToDevicePixels="true" /> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter TargetName="Border" Property="Stroke" Value="Gray" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate>

    Read the article

  • Why does this textbox binding example work in WPF but not in Silverlight?

    - by Edward Tanguay
    Why is it in the following silverlight application that when I: change the default text in the first textbox move the cursor to the second text box (i.e. take focus off first textbox) click the button that inside the button handler, it still has the old value "default text"? What do I have to do to get the binding to work in Silverlight? The same code works fine in WPF. XAML: <UserControl x:Class="TestUpdate123.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <StackPanel Margin="10" HorizontalAlignment="Left"> <TextBox Text="{Binding InputText}" Height="200" Width="600" Margin="0 0 0 10"/> <StackPanel HorizontalAlignment="Left"> <Button Content="Convert" Click="Button_Convert_Click" Margin="0 0 0 10"/> </StackPanel> <TextBox Height="200" Width="600" Margin="0 0 0 10"/> <TextBlock Text="{Binding OutputText}"/> </StackPanel> </UserControl> Code Behind: using System.Windows; using System.Windows.Controls; using System.ComponentModel; namespace TestUpdate123 { public partial class MainPage : UserControl, INotifyPropertyChanged { #region ViewModelProperty: InputText private string _inputText; public string InputText { get { return _inputText; } set { _inputText = value; OnPropertyChanged("InputText"); } } #endregion #region ViewModelProperty: OutputText private string _outputText; public string OutputText { get { return _outputText; } set { _outputText = value; OnPropertyChanged("OutputText"); } } #endregion public MainPage() { InitializeComponent(); DataContext = this; InputText = "default text"; } private void Button_Convert_Click(object sender, RoutedEventArgs e) { OutputText = InputText; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } }

    Read the article

  • Trouble passing a string as a SQLite ExecSQL command

    - by Hackbrew
    I keep getting the ERROR: near "PassWord": syntax error when trying to execute the ExecSQL() statement. The command looks good in the output of the text file. In fact, I copied & pasted the command directly into SQLite Database Browser and the commend executed properly. Here's the code that's producing the error: procedure TForm1.Button1Click(Sender: TObject); var i, iFieldSize: integer; sFieldName, sFieldType, sFieldList, sExecSQL: String; names: TStringList; f1: Textfile; begin //Open Source table - Table1 has 8 fields but has only two different field types ftString and Boolean Table1.TableName:= 'PWFile'; Table1.Open; //FDConnection1.ExecSQL('drop table PWFile'); sFieldList := ''; names := TStringList.Create; for i := 0 to Table1.FieldCount - 1 do begin sFieldName := Table1.FieldDefList.FieldDefs[i].Name; sFieldType := GetEnumName(TypeInfo(TFieldType),ord(Table1.FieldDefList.FieldDefs[i].DataType)); iFieldSize := Table1.FieldDefList.FieldDefs[i].Size; if sFieldType = 'ftString' then sFieldType := 'NVARCHAR' + '(' + IntToStr(iFieldSize) + ')'; if sFieldType = 'ftBoolean' then sFieldType := 'INTEGER'; names.Add(sFieldName + ' ' + sFieldType); if sFieldList = '' then sFieldList := sFieldName + ' ' + sFieldType else sFieldList := sFieldList + ', ' + sFieldName + ' ' + sFieldType; end; ListBox1.Items.Add(sFieldList); sExecSQL := 'create table IF NOT EXISTS PWFile (' + sFieldList + ')'; // 08/18/2014 - Entered this to log the SQLite FDConnection1.ExecSQL Command to a file AssignFile(f1, 'C:\Users\Test User\Documents\SQLite_Command.txt'); Rewrite(f1); Writeln(f1, sExecSQL); { insert code here that would require a Flush before closing the file } Flush(f1); { ensures that the text was actually written to file } CloseFile(f1); FDConnection1.ExecSQL(sFieldList); Table1.Close; end; Here's the actual command that gets executed: create table IF NOT EXISTS PWFile (PassWord NVARCHAR(10), PassName NVARCHAR(10), Dept NVARCHAR(10), Active NVARCHAR(1), Admin INTEGER, Shred INTEGER, Reports INTEGER, Maintain INTEGER)

    Read the article

  • ASP.NET Elements are null when assigning data source

    - by deccks
    For some reason, all of the objects in my ASP.NET markup are now null when I try to assign values to their properties in the code behind. My project was going fine and then now when I try to assign a data source to a GridView, I get a null reference error. I have no idea why it's doing this. I am not doing nothing special. I am just trying to assign a value to a property to an asp.net element in on the page. The intellisense knows that the element is there and I get no errors when I build the project. It's just when I am running the website I get the null reference. I have been trying to fix this issue for a couple weeks now. Please Help. Thanks. Here is the code: protected void Page_PreRender(object sender, EventArgs e) { LoadData(); } private void LoadData() { Entities context = new Entities(); var types = (from t in context.CustomerTypes select t).OrderBy(t => t.TypeName); gvCustomerTypes.DataSource = types; gvCustomerTypes.DataBind(); } and on in the markup the gridview looks like this: <asp:GridView ID="gvCustomerTypes" runat="server" ShowHeader="true" GridLines="Both" AutoGenerateColumns="false" AlternatingRowStyle-BackColor="AliceBlue" Width="100%"> <Columns> <asp:TemplateField HeaderText="Customer Type Name" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"> <ItemTemplate> <asp:Label ID="lblType" runat="server" Text='<%# Eval("TypeName") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:HyperLink ID="HyperLink1" NavigateUrl='<%#Eval("CustomerTypeID", "CreateEditCustomerType.aspx?ID={0}") %>' Text="Edit" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Delete" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:LinkButton ID="LinkButton1" CommandName='<%#Eval("CustomerTypeID") %>' OnClientClick="javascript:return confirm('Are you sure you want to delete this Customer Type?');" OnCommand="DeleteCustomerType" Text="Delete" runat="server" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>

    Read the article

  • Assembly Load and loading the "sub-modules" dependencies - "cannot fild the file specified"

    - by Ted
    There are several questions out there that ask the same question. However the answers they received I cannot understand, so here goes: Similar questions: http://stackoverflow.com/questions/1874277/dynamically-load-assembly-and-manually-force-path-to-get-referenced-assemblies ; http://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies-closed The question in short: I need to figure out how dependencies, ie References in my modules can be loaded dynamically. Right now I am getting "The system cannot find the file specified" on Assemblies referenced in my so called modules. I cannot really get how to use the AssemblyResolve event... The longer version I have one application, MODULECONTROLLER, that loads separate modules. These "separate modules" are located in well-known subdirectories, like appBinDir\Modules\Module1 appBinDir\Modules\Module2 Each directory contains all the DLLs that exists in the bin-directory of those projects after a build. So the MODULECONTROLLER loads all the DLLs contained in those folders using this code: byte[] bytes = File.ReadAllBytes(dllFileFullPath); Assembly assembly = null; assembly = Assembly.Load(bytes); I am, as you can see, loading the byte[]-array (so I dont lock the DLL-files). Now, in for example MODULE1, I have a static reference called MyGreatXmlProtocol. The MyGreatXmlProtocol.dll then also exists in the directory appBinDir\Modules\Module1 and is loaded using the above code When code in the MODULE1 tries to use this MyGreatXmlProtocol, I get: Could not load file or assembly 'MyGreatXmlProtocol, Version=1.0.3797.26527, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. So, in a post (like this one) they say that To my understanding reflection will load the main assembly and then search the GAC for the referenced assemblies, if it cannot find it there, you can then incorparate an assemblyResolve event: First; is it really needed to use the AssemblyResolve-event to make this work? Shouldnt my different MODULEs themself load their DLLs, as they are statically referenced? Second; if AssemblyResolve is the way to go - how do I use it? I have attached a handler to the Event but I never get anything on MyGreatXmlProctol... === EDIT === CODE regarding the AssemblyResolve-event handler: public GUI() { InitializeComponent(); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); ... } // Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Console.WriteLine(args.Name); return null; } Hope I wasnt too fuzzy =) Thx

    Read the article

  • WPF - Two way binding use a user control...binding to object, not an element!

    - by Scott
    I created an object with a simple property with a default value. I then created a user control that has a text box in it. I set the datacontext of the user control to the object. The text box correctly shows the properties default value but I can't seem to update the property value when the user changes the text box value. I created a simple project to illustrate my code. Thanks for the help!! public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } private string _titleValue; public string TitleValue { get { return _titleValue; } set { _titleValue = value; textBox1.Text = _titleValue; } } public static readonly DependencyProperty TitleValueProperty = DependencyProperty.Register( "TitleValue", typeof(string), typeof(UserControl1), new FrameworkPropertyMetadata(new PropertyChangedCallback(titleUpdated)) ); //Don't think I should need to do this!!! private static void titleUpdated(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((UserControl1)d).TitleValue = (string)e.NewValue; } } <UserControl x:Class="WpfApplication1.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <TextBox Height="23" HorizontalAlignment="Left" Margin="94,97,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" Text="{Binding Path=TitleValue, Mode=TwoWay}"/> </Grid> </UserControl> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var dummy = new DummyObject("This is my title."); userControl11.DataContext = dummy; } private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show("The value is: " + ((DummyObject)userControl11.DataContext).Title); } } <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:my="clr-namespace:WpfApplication1"> <Grid> <my:UserControl1 HorizontalAlignment="Left" Margin="95,44,0,0" x:Name="userControl11" VerticalAlignment="Top" Height="191" Width="293" TitleValue="{Binding Path=Title, Mode=TwoWay}"/> <Button Content="Check Value" Height="23" HorizontalAlignment="Left" Margin="20,12,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> </Grid> </Window>

    Read the article

  • Get data from aspx.cs page to aspx page.

    - by Brad8118
    So I am using a jquery plug in that allows me to change the order of things in a list by dragging and dropping them. So my goal is to be able to grab a list of my objects (AlertInfo) and using it in a javascript function. I was able to use a json webservice call in a test project to pass the data to the page. But we don't have a webservice page now so I tried to grab it from a aspx.cs page and it hasn't worked. ///Aspx page: $.ajax({ type: "POST", url: "~/Alerts/GetAlerts", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { var data = eval("(" + msg.d + ")"); jQuery.each(data, function (rec) { AlertList[AlertList.length] = new objAlert(this.id, this.title, this.details, JSONDateSerializationFix(this.startdate), JSONDateSerializationFix(this.enddate)); UpdateDisplayList(); }) }, error: function (msg) { alert("BRAD" + msg); } The issue is that the Alerts page in "URL /Alerts/GetAlerts" is Alerts.aspx.cs. I can't figure out if I can use this ajax command to call a method in a aspx.cs page. //Code behind page aspx.cs [WebMethod] //[ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetAlerts() { List list = AlertInfo.GetTestAlerts(); return new JavaScriptSerializer().Serialize(list); } public List GetAlertsList() { List list = AlertInfo.GetTestAlerts(); return list; ; } So I was hoping that I could load data into an asp control (dataList) and then grab the data //code behind page protected void Page_Load(object sender, EventArgs e) { dataListAlertList.DataSource = GetAlertsList(); dataListAlertList.DataBind(); } public static List<AlertInfo> GetTestAlerts() { List<AlertInfo> list = new List<AlertInfo>(); list.Add(new AlertInfo("0", "Alert 1 Title", "Alert 1 Detail", "10/10/2010", "10/10/2011")); list.Add(new AlertInfo("1", "Alert 2 Title", "Alert 2 Detail", "10/10/2010", "10/10/2011")); return list; } //.aspx page $(document).ready(function () { var a1 = $("#dataListAlertList").val(); // do fun stuff now. } But I keep getting undefined....

    Read the article

  • Equivalent of System.Windows.Forms.Cursor in Web Application

    - by Vishwa
    Hi I have a code in windows application now i am trying to implement in web Application but it is showimg that it ths no cursor class (System.Windows.Forms.Cursor )so..wat is the equivalent in web application. Here is my code private void btnGo_Click(System.Object sender, System.EventArgs e) { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); // Load the images. Bitmap bm1 = (Bitmap) (Image.FromFile(txtFile1.Text)); Bitmap bm2 = (Bitmap) (Image.FromFile(txtFile2.Text)); // Make a difference image. int wid = Math.Min(bm1.Width, bm2.Width); int hgt = Math.Min(bm1.Height, bm2.Height); Bitmap bm3 = new Bitmap(wid, hgt); // Create the difference image. bool are_identical = true; int r1; int g1; int b1; int r2; int g2; int b2; int r3; int g3; int b3; Color eq_color = Color.White; Color ne_color = Color.Transparent; for (int x = 0; x <= wid - 1; x++) { for (int y = 0; y <= hgt - 1; y++) { if (bm1.GetPixel(x, y).Equals(bm2.GetPixel(x, y))) { bm3.SetPixel(x, y, eq_color); } else { bm1.SetPixel(x, y, ne_color); are_identical = false; } } } // Display the result. picResult.Image = bm1; Bitmap Logo = new Bitmap(picResult.Image); Logo.MakeTransparent(Logo.GetPixel(1, 1)); picResult.Image = (Image)Logo; this.Cursor = Cursors.Default; if ((bm1.Width != bm2.Width) || (bm1.Height != bm2.Height)) { are_identical = false; } if (are_identical) { MessageBox.Show("The images are identical"); } else { MessageBox.Show("The images are different"); } //bm1.Dispose() // bm2.Dispose() }

    Read the article

  • Chrome extension - Localstorage not working

    - by Bjarki Jonasson
    I'm writing a Chrome extension that uses a content script to modify certain parts of a website. The content script worked fine until I tried to add an options page to my extension. Right now I'm using an options.html file to save user preferences to localstorage, as you can see here: <html> <head><title>Options</title></head> <script type="text/javascript"> function save_options() { var select = document.getElementById("width"); var width = select.children[select.selectedIndex].value; localStorage["site_width"] = width; } function restore_options() { var fwidth = localStorage["site_width"]; if (!fwidth) { return; } var select = document.getElementById("width"); for (var i = 0; i < select.children.length; i++) { var child = select.children[i]; if (child.value == fwidth) { child.selected = "true"; break; } } } </script> <body onload="restore_options()"> Width: <select id="width"> <option value="100%">100%</option> <option value="90%">90%</option> <option value="80%">80%</option> <option value="70%">70%</option> </select> <br> <button onclick="save_options()">Save</button> </body> </html> I also have a background.html file to handle the communication between the content script and the localstorage: <html> <script type="text/javascript"> chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { if (request.method == "siteWidth") sendResponse({status: localStorage["site_width"]}); else sendResponse({}); }); </script> </html> Then there's the actual content script that looks like this: var Width; chrome.extension.sendRequest({method: "siteWidth"}, function(response) { width = response.status; }); None of that code actually works. It looks solid enough to me but I'm not a very experienced programmer so I might be wrong. Could someone explain localstorage to me in layman's terms?

    Read the article

  • Delphi - Read File To StringList, then delete and write back to file.

    - by Jkraw90
    I'm currently working on a program to generate the hashes of files, in Delphi 2010. As part of this I have a option to create User Presets, e.g. pre-defined choice of hashing algo's which the user can create/save/delete. I have the create and load code working fine. It uses a ComboBox and loads from a file "fhpre.ini", inside this file is the users presets stored in format of:- PresetName PresetCode (a 12 digit string using 0 for don't hash and 1 for do) On application loading it loads the data from this file into the ComboBox and an Array with the ItemIndex of ComboBox matching the corrisponding correct string of 0's and 1's in the Array. Now I need to implement a feature to have the user delete a preset from the list. So far my code is as follows, procedure TForm1.Panel23Click(Sender : TObject); var fil : textfile; contents : TStringList; x,i : integer; filline : ansistring; filestream : TFileStream; begin //Start Procedure //Load data into StringList contents := TStringList.Create; fileStream := TFileStream.Create((GetAppData+'\RFA\fhpre.ini'), fmShareDenyNone); Contents.LoadFromStream(fileStream); fileStream.Destroy(); //Search for relevant Preset i := 0; if ComboBox4.Text <> Contents[i] then begin Repeat i := i + 1; Until ComboBox4.Text = Contents[i]; end; contents.Delete(i); //Delete Relevant Preset Name contents.Delete(i); //Delete Preset Digit String //Write StringList back to file. AssignFile(fil,(GetAppData+'\RFA\fhpre.ini')); ReWrite(fil); for i := 0 to Contents.Count -1 do WriteLn(Contents[i]); CloseFile(fil); Contents.Free; end; However if this is run, I get a 105 error when it gets to the WriteLn section. I'm aware that the code isn't great, for example doesn't have checks for presets with same name, but that will come, I want to get the base code working first then can tweak and add extra checks etc. Any help would be appreciated.

    Read the article

  • Windows Phone period task, function not executing

    - by Special K.
    I'm trying to execute a code (to parse an XML to be more precisely, and after that I'll toast message the user with some new info's), but the class function AccDetailsDownloaded is not executed (is simply skipped), also the memory usage is ~2mb out of 6, here is my code: if (task is PeriodicTask) { getData(); } else { getData(); } // If debugging is enabled, launch the agent again in one minute. #if DEBUG_AGENT ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60)); #endif // Call NotifyComplete to let the system know the agent is done working. NotifyComplete(); } public void getData() { var settings = IsolatedStorageSettings.ApplicationSettings; string url = "http://example.com/example.xml"; if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { MessageBox.Show("No network connection available!"); return; } // start loading XML-data WebClient downloader = new WebClient(); Uri uri = new Uri(url, UriKind.Absolute); downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(AccDetailsDownloaded); downloader.DownloadStringAsync(uri); string toastTitle = ""; toastTitle = "Periodic "; string toastMessage = "Mem usage: " + DeviceStatus.ApplicationPeakMemoryUsage + "/" + DeviceStatus.ApplicationMemoryUsageLimit; // Launch a toast to show that the agent is running. // The toast will not be shown if the foreground application is running. ShellToast toast = new ShellToast(); toast.Title = toastTitle; toast.Content = toastMessage; toast.Show(); } void AccDetailsDownloaded(object sender, DownloadStringCompletedEventArgs e) { if (e.Result == null || e.Error != null) { MessageBox.Show("There was an error downloading the XML-file!"); } else { string toastTitle = ""; toastTitle = "Periodic "; string toastMessage = "Mem usage: " + DeviceStatus.ApplicationPeakMemoryUsage + "/" + DeviceStatus.ApplicationMemoryUsageLimit; // Launch a toast to show that the agent is running. // The toast will not be shown if the foreground application is running. ShellToast toast = new ShellToast(); toast.Title = toastTitle; toast.Content = toastMessage; toast.Show(); } } Thank you.

    Read the article

  • Why is this simple Mobile Form not closed when using the player

    - by ajhvdb
    Hi, I created this simple sample Form with the close button. Everything is working as expected when NOT using the Interop.WMPLib.dll I've seen other applications using this without problems but why isn't the Form process closed when I just add the line: SoundPlayer myPlayer = new SoundPlayer(); and of course dispose it: if (myPlayer != null) { myPlayer.Dispose(); myPlayer = null; } The Form closes but the debugger VS2008 is still active. The Form project and the dll are still active. If you send me an email to [email protected], I can send you the zipped project. Below is the class for the dll: using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Runtime.InteropServices; using WMPLib; namespace WindowsMobile.Utilities { public delegate void SoundPlayerStateChanged(SoundPlayer sender, SoundPlayerState newState); public enum SoundPlayerState { Stopped, Playing, Paused, } public class SoundPlayer : IDisposable { [DllImport("coredll")] public extern static int waveOutSetVolume(int hwo, uint dwVolume); [DllImport("coredll")] public extern static int waveOutGetVolume(int hwo, out uint dwVolume); WindowsMediaPlayer myPlayer = new WindowsMediaPlayer(); public SoundPlayer() { myPlayer.uiMode = "invisible"; myPlayer.settings.volume = 100; } string mySoundLocation = string.Empty; public string SoundLocation { get { return mySoundLocation; } set { mySoundLocation = value; } } public void Pause() { myPlayer.controls.pause(); } public void PlayLooping() { Stop(); myPlayer.URL = mySoundLocation; myPlayer.settings.setMode("loop", true); } public int Volume { get { return myPlayer.settings.volume; } set { myPlayer.settings.volume = value; } } public void Play() { Stop(); myPlayer.URL = mySoundLocation; myPlayer.controls.play(); } public void Stop() { myPlayer.controls.stop(); myPlayer.close(); } #region IDisposable Members public void Dispose() { try { Stop(); } catch (Exception) { } // need this otherwise the process won't exit?! try { int ret = Marshal.FinalReleaseComObject(myPlayer); } catch (Exception) { } myPlayer = null; GC.Collect(); } #endregion } }

    Read the article

  • JavaScript code inside UpdatePanel

    - by Ed Woodcock
    Ok: I've got an UpdatePanel on an aspx page that contains a single Placeholder. Inside this placeholder I'm appending one of a selection of usercontrols depending on certain external conditions (this is a configuration page). In each of these usercontrols there is a bindUcEvents() javascript function that binds the various jQuery and javascript events to buttons and validators inside the usercontrol. The issue I'm having is that the usercontrol's javascript is not being recognised. Normally, javascript inside an updatepanel is executed when the updatepanel posts back, however none of this code can be found by the page (I've tried running the function manually via firebug's console, but it tells me it cannot find the function). Does anyone have any suggestions? Cheers, Ed. EDIT: cut down (but functional) example: Markup: <script src="/js/jquery-1.3.2.min.js"></script> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="Script" runat="server" /> <asp:Button ID="Postback" runat="server" Text="Populate" OnClick="PopulatePlaceholder" /> <asp:UpdatePanel ID="UpdateMe" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Postback" EventName="Click" /> </Triggers> <ContentTemplate> <asp:Literal ID="Code" runat="server" /> <asp:PlaceHolder ID="PlaceMe" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> C#: protected void PopulatePlaceholder(object sender, EventArgs e) { Button button = new Button(); button.ID = "Push"; button.Text = "push"; button.OnClientClick = "javascript:return false;"; Code.Text = "<script type=\"text/javascript\"> function bindEvents() { $('#" + button.ClientID + "').click(function() { alert('hello'); }); } bindEvents(); </script>"; PlaceMe.Controls.Add(button); } You'll see that the button does not poput the alert message, even though the code is present on the page.

    Read the article

  • AFNetworking PostPath php Parameters are null

    - by Alejandro Escobar
    I am trying to send a username and password from an iOS app using AFNetworking framework to a php script. The iOS app continues to receive status code 401 which I defined to be "not enough parameters". I have tried returning the "username" from the php script to the iOS app and receive . Based on what I've been investigating so far, it seems as though: 1) The php script is not decoding the POST parameters properly 2) The iOS app is not sending the POST parameters properly The following is the iOS function - (IBAction)startLoginProcess:(id)sender { NSString *usernameField = usernameTextField.text; NSString *passwordField = passwordTextField.text; NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:usernameField, @"username", passwordField, @"password", nil]; NSURL *url = [NSURL URLWithString:@"http://localhost/~alejandroe1790/edella_admin/"]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; [httpClient defaultValueForHeader:@"Accept"]; [httpClient setParameterEncoding:AFJSONParameterEncoding]; [httpClient postPath:@"login.php" parameters:parameters success:^(AFHTTPRequestOperation *operation, id response) { NSLog(@"operation hasAcceptableStatusCode: %d", [operation.response statusCode]); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error with request"); NSLog(@"%@",[error localizedDescription]); }]; } The following is the php script function checkLogin() { // Check for required parameters if (isset($_POST["username"]) && isset($_POST["password"])) { //Put parameters into local variables $username = $_POST["username"]; $password = $_POST["password"]; $stmt = $this->db->prepare("SELECT Password FROM Admin WHERE Username=?"); $stmt->bind_param('s', $username); $stmt->execute(); $stmt->bind_result($resultpassword); while ($stmt->fetch()) { break; } $stmt->close(); // Username or password invalid if ($password == $resultpassword) { sendResponse(100, 'Login successful'); return true; } else { sendResponse(400, 'Invalid Username or Password'); return false; } } sendResponse(401, 'Not enough parameters'); return false; } I feel like I may be missing something. Any assistance would be great.

    Read the article

  • Pass param to a silverlight application

    - by Lucas_Santos
    In my javascript I create my <OBJECT> tag var htmlEmbedSilverlight = "<div id='silverlightControlHost'> " + "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='550px' height='250px'> " + "<param name='source' value='../../ClientBin/FotoEmprestimoChave.xap'/> " + "<param name='onError' value='onSilverlightError' /> " + "<param name='background' value='white' /> " + "<param name='minRuntimeVersion' value='4.0.60310.0' /> " + "<param name='autoUpgrade' value='true' /> " + "<param name='initparams' values='chave_id=" + data + "' /> " + "<a href='http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0' style='text-decoration:none'> " + "<img src='http://go.microsoft.com/fwlink/?LinkId=161376' alt='Get Microsoft Silverlight' style='border-style:none'/> " + "</a> " + "</object><iframe id='_sl_historyFrame' style='visibility:hidden;height:0px;width:0px;border:0px'></iframe></div>"; $("#tiraFotoSilverlight").html(htmlEmbedSilverlight); This is a reference to my Silverlight application where I call in my Web Application. The problem is my <param name='initparams' values='chave_id=" + data + "' /> " because in my App.xaml in Silverlight, I have the code below private void Application_Startup(object sender, StartupEventArgs e) { if (e.InitParams != null) { foreach (var item in e.InitParams) { this.Resources.Add(item.Key, item.Value); } } this.RootVisual = new MainPage(); } Where InitParams always has Count = 0 and I don't know why. Can someone help me ? I'm just trying to pass a value to my Silverlight application, without a PostBack. Rendered <object width="550px" height="250px" type="application/x-silverlight-2" data="data:application/x-silverlight-2,"> <param value="../../ClientBin/FotoEmprestimoChave.xap" name="source"> <param value="onSilverlightError" name="onError"> <param value="white" name="background"> <param value="4.0.60310.0" name="minRuntimeVersion"> <param value="true" name="autoUpgrade"> <param values="chave_id=1" name="initparams"> <a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0"> </object>

    Read the article

  • Need help helping in converting jquery, ajax, json and asp.net

    - by Haja Mohaideen
    I am tying out this tutorial, http://www.ezzylearning.com/tutorial.aspx?tid=5869127. It works perfectly. What I am now trying to do is to host the aspx contents as html file. This html file is hosted on my wampserver which is on my laptop. The asp.net code hosted on my test server. When I try to access, I get the following error, Resource interpreted as Script but transferred with MIME type text/html: "http://201.x.x.x/testAjax/Default.aspx/AddProductToCart?callback=jQuery17103264484549872577_1346923699990&{%20pID:%20%226765%22,%20qty:%20%22100%22,%20lblType:%20%2220%22%20}&_=1346923704482". jquery.min.js:4 Uncaught SyntaxError: Unexpected token < I am not sure how to solve this problem. index.html code $(function () { $('#btnAddToCart').click(function () { var result = $.ajax({ type: "POST", url: "http://202.161.45.124/testAjax/Default.aspx/AddProductToCart", crossDomain: true, data: '{ pID: "6765", qty: "100", lblType: "20" }', contentType: "application/json; charset=utf-8", dataType: "jsonp", success: succeeded, failure: function (msg) { alert(msg); }, error: function (xhr, err) { alert(err); } }); }); }); function succeeded(msg) { alert(msg.d); } function btnAddToCart_onclick() { } </script> </head> <body> <form name="form1" method="post"> <div> <input type="button" id="btnAddToCart" onclick="return btnAddToCart_onclick()" value="Button" /> </div> </form> aspx.vb Imports System.Web.Services Imports System.Web.Script.Services <ScriptService()> Public Class WebForm1 Inherits Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Session("test") = "" End Sub <WebMethod()> <ScriptMethod(UseHttpGet:=False, ResponseFormat:=ResponseFormat.Json)> Public Shared Function AddProductToCart(pID As String, qty As String, lblType As String) As String Dim selectedProduct As String = String.Format("+ {0} - {1} - {2}", pID, qty, lblType) HttpContext.Current.Session("test") += selectedProduct Return HttpContext.Current.Session("test").ToString() End Function End Class

    Read the article

  • disable dates using jquery inside gridview control

    - by bladerunner
    Hi there, I have a gridview which contains a textbox control. I need to show the calendar for the user to pick the date and certain dates are to be disabled using jquery. I found a post on stackoverflow that talked about how to disable certain dates. I am done with that part, except not sure how to pass the textbox control to this jquery function. Here is the code. <script type="text/javascript" language="javascript"> function pageLoad(sender, args) { var enabledDays = ['09/21/2011', '10/05/2011', '10/19/2011', '11/02/2011', '11/16/2011']; /* utility functions */ function editDays(date) { for (var i = 0; i < enabledDays.length; i++) { if (new Date(enabledDays[i]).toString() == date.toString()) { return [true]; } } return [false]; } /* create datepicker */ $(document).ready(function() { $('#<%= txtInHomeDate.ClientID %>').datepicker({ beforeShow: springDate, beforeShowDay: editDays, dateFormat: 'mm/dd/yy', buttonImage: 'images/cal.gif', buttonText: 'Choose date', firstDay: 1, buttonImageOnly: true, showOn: 'both', showAnim: 'fadeIn', onSelect: function() { $(this).trigger("onchange", null); } }); function springDate() { var defaultMin = new Date(); var defaultMax = new Date(); var Min = defaultMin; var Max = defaultMax; // make valid date from hiddenfied value format is MM/dd/yyyy dateMin = $('#<%= hfStDate.ClientID %>').val(); dateMin = new Date(dateMin); dateMax = $('#<%= hfEndDate.ClientID %>').val(); dateMax = new Date(dateMax); if (dateMin && dateMax) { Min = new Date(dateMin.getFullYear(), dateMin.getMonth(), dateMin.getDate()); Max = new Date(dateMax.getFullYear(), dateMax.getMonth(), dateMax.getDate()); } return { minDate: Min, maxDate: Max }; } }); } <.... <asp:TemplateField HeaderText="In-Home Date"> <ItemStyle HorizontalAlign="Center" /> <ItemTemplate> <asp:HiddenField ID="hfStDate" runat="server" Value="09/01/2011" /> <asp:HiddenField ID="hfEndDate" runat="server" Value="11/30/2011" /> <asp:TextBox ID="txtInHomeDate" runat="server" /> </ItemTemplate> </asp:TemplateField> Currently, it errors out since the jquery function won't find the txtInHomeDate. Could I get some help as I am pretty close to get this done? Thanks!!

    Read the article

  • how to set objectForKey to UISwitch to access switch for save selected option

    - by Rkm
    SystemUIViewcontroller has button event. Tap on Button fire InfoTableviewController. InfoTableview has UISwitch. How to set objectForKey to Info to access UIswitch ViewDidload of System... - (void)viewDidLoad { [super viewDidLoad]; self.Infoarray = [NSMutableArray array]; Info *info = [[Info alloc]initWithNibName:@"Info" bundle:nil]; [self.Infoarray addObject:[NSDictionary dictionaryWithObjectsAndKeys:info, @"viewController", nil]]; } SystemUIviewcontroller button event... -(IBAction) Info_Button_Clicked:(id) sender { Info *info = [[Info alloc]initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:info animated:YES]; [info release]; } Here for Info TableviewController... - (void)viewDidLoad { [super viewDidLoad]; self.Soundarray = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @"Sounds", @"labelKey", self.SoundsswitchCtl, @"viewKey", nil],nil]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; if ([indexPath section] == 0) { static NSString *kDisplayCell_ID = @"DisplayCellID"; cell = [self.tableView dequeueReusableCellWithIdentifier: kDisplayCell_ID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: kDisplayCell_ID] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } else { // the cell is being recycled, remove old embedded controls UIView *viewToRemove = nil; viewToRemove = [cell.contentView viewWithTag:1]; if (viewToRemove) [viewToRemove removeFromSuperview]; } cell.textLabel.text = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"labelKey"]; UIControl *control = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"viewKey"]; [cell.contentView addSubview:control]; return cell; } } - (UISwitch *)SoundsswitchCtl { if (SoundsswitchCtl == nil) { CGRect frame = CGRectMake(198.0, 12.0, 94.0, 27.0); SoundsswitchCtl = [[UISwitch alloc] initWithFrame:frame]; [SoundsswitchCtl addTarget:self action:@selector(switch_Sounds:) forControlEvents:UIControlEventValueChanged]; // in case the parent view draws with a custom color or gradient, use a transparent color SoundsswitchCtl.backgroundColor = [UIColor clearColor]; [SoundsswitchCtl setAccessibilityLabel:NSLocalizedString(@"StandardSwitch", @"")]; SoundsswitchCtl.tag = 1; // tag this view for later so we can remove it from recycled table cells } return SoundsswitchCtl; }

    Read the article

  • .NET Windows Service with timer stops responding

    - by Biri
    I have a windows service written in c#. It has a timer inside, which fires some functions on a regular basis. So the skeleton of my service: public partial class ArchiveService : ServiceBase { Timer tickTack; int interval = 10; ... protected override void OnStart(string[] args) { tickTack = new Timer(1000 * interval); tickTack.Elapsed += new ElapsedEventHandler(tickTack_Elapsed); tickTack.Start(); } protected override void OnStop() { tickTack.Stop(); } private void tickTack_Elapsed(object sender, ElapsedEventArgs e) { ... } } It works for some time (like 10-15 days) then it stops. I mean the service shows as running, but it does not do anything. I make some logging and the problem can be the timer, because after the interval it does not call the tickTack_Elapsed function. I was thinking about rewrite it without a timer, using an endless loop, which stops the processing for the amount of time I set up. This is also not an elegant solution and I think it can have some side effects regarding memory. The Timer is used from the System.Timers namespace, the environment is Windows 2003. I used this approach in two different services on different servers, but both is producing this behavior (this is why I thought that it is somehow connected to my code or the framework itself). Does somebody experienced this behavior? What can be wrong? Edit: I edited both services. One got a nice try-catch everywhere and more logging. The second got a timer-recreation on a regular basis. None of them stopped since them, so if this situation remains for another week, I will close this question. Thank you for everyone so far. Edit: I close this question because nothing happened. I mean I made some changes, but those changes are not really relevant in this matter and both services are running without any problem since then. Please mark it as "Closed for not relevant anymore".

    Read the article

  • Error With Sending mail (kSKPSMTPPartMessageKey is nil)

    - by user1553381
    I'm trying to send mail in iPhone using "SKPSMTPMessage" and I added the libraries, In my class I added the following code: - (IBAction)sendMail:(id)sender { // if there are a connection if ([theConnection isEqualToString:@"true"]) { if ([fromEmail.text isEqualToString:@""] || [toEmail.text isEqualToString:@""]) { UIAlertView *warning = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ??? ????? ???? ????????" delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [warning show]; }else { SKPSMTPMessage *test_smtp_message = [[SKPSMTPMessage alloc] init]; test_smtp_message.fromEmail = fromEmail.text; test_smtp_message.toEmail = toEmail.text; test_smtp_message.relayHost = @"smtp.gmail.com"; test_smtp_message.requiresAuth = YES; test_smtp_message.login = @"[email protected]"; test_smtp_message.pass = @"myPass"; test_smtp_message.wantsSecure = YES; NSString *subject= @"Suggest a book for you"; test_smtp_message.subject = [NSString stringWithFormat:@"%@ < %@ > ",fromEmail.text, subject]; test_smtp_message.delegate = self; NSMutableArray *parts_to_send = [NSMutableArray array]; NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey, [messageBody.text stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey, @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey, nil]; [parts_to_send addObject:plain_text_part]; // to send attachment NSString *image_path = [[NSBundle mainBundle] pathForResource:BookCover ofType:@"jpg"]; NSData *image_data = [NSData dataWithContentsOfFile:image_path]; NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys: @"inline;\r\n\tfilename=\"image.png\"",kSKPSMTPPartContentDispositionKey, @"base64",kSKPSMTPPartContentTransferEncodingKey, @"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666",kSKPSMTPPartContentTypeKey, [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey, nil]; [parts_to_send addObject:image_part]; test_smtp_message.parts = parts_to_send; Spinner.hidden = NO; [Spinner startAnimating]; ProgressBar.hidden = NO; HighestState = 0; [test_smtp_message send]; } }else { UIAlertView *alertNoconnection = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ???? ???? " delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [alertNoconnection show]; } } but when I tried to send it gives me the following Exception: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString appendString:]: nil argument' and it highlighted this line in SKPSMTPMessage.m [message appendString:[part objectForKey:kSKPSMTPPartMessageKey]]; and I Can't understand what is nil exactly Can Anyone help me in this issue? Thanks in Advance.

    Read the article

  • Strange behaviour on postback in ASP.NET

    - by C-King
    I'm working on a website with a login form. To log in, a postback is used to an OnClick handler in the codebehind. Somehow, the value returned from the Text-property of the username and password textboxes is ten times the value I entered, separated by commas. I checked my entire code for double ID's (which seems to be the most common problem causing this behaviour), but I found each ID defined only once. In the ASPX file I have this: <asp:Label ID="lblFeedback" ForeColor="Red" Font-Bold="true" runat="server" Visible="false" /><br /> <asp:Panel ID="pnlLogin" runat="server"> <table style="border-style: none;"> <tr> <td> <asp:Label ID="lblUsername" AssociatedControlID="txtUsername" runat="server" /> </td> <td> <asp:TextBox ID="txtUsername" runat="server" /><br /> </td> </tr> <tr> <td> <asp:Label ID="lblPassword" AssociatedControlID="txtPassword" runat="server" /> </td> <td> <asp:TextBox ID="txtPassword" runat="server" TextMode="password" /><br /> </td> </tr> <tr> <td> </td> <td> <asp:Button ID="btnLogin" OnClick="btnLogin_Click" runat="server" /> </td> </tr> </table> </asp:Panel> The OnClick handler in the Codebehind: protected void btnLogin_Click(object sender, EventArgs e) { string username = Util.Escape(txtUsername.Text); string password = Util.Escape(txtPassword.Text); WebsiteUser user = WebsiteUser.Create(username, password); if (user != null) { //Set some session variables and redirect to user profile } else { lblFeedback.Text = Localizer.Translate("INVALID_LOGIN"); lblFeedback.ForeColor = Color.Red; lblFeedback.Visible = true; pnlLogin.Visible = true; } } The website is running on ASP.NET 2.0 on ISS 5.1 (Win XP Pro)

    Read the article

  • C#: Label contains no text

    - by Vinzcent
    Hey I would like to get the text out of a label. But the label text is set with Javascript. On the page I can see that there is text in the label, but when I debug it shows this: "". So how do I get the text out of a label that is set with Javascript, at least that is what I think is the problem. My code: <asp:TextBox ID="txtCount" runat="server" Width="50px" Font-Names="Georgia, Arial, sans-Serif" ForeColor="#444444"></asp:TextBox> <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" Minimum="1" TargetButtonDownID="btnDown" TargetButtonUpID="btnUp" TargetControlID="txtCount" Width="20" /> <asp:ImageButton ID="btnUp" runat="server" AlternateText="up" ImageUrl="Images/arrowUp.png" OnClientClick="setAmountUp()" ImageAlign="Top" CausesValidation="False" /> <asp:ImageButton ID="btnDown" runat="server" AlternateText="down" ImageUrl="Images/arrowDown.png" OnClientClick="setAmountDown()" ImageAlign="Bottom" CausesValidation="False" /> <asp:Label ID="lblKorting" runat="server" /> <asp:Label ID="lblAmount" runat="server" /> <asp:Button ID="btnBestel" runat="server" CssClass="btn" Text="Bestel" OnClick="btnBestel_Click1" /> JS function setAmountUp() { var aantal = document.getElementById('<%=txtCount.ClientID%>').value-0; aantal+=1; calculateAmount(aantal); } function setAmountDown() { var aantal = document.getElementById('<%=txtCount.ClientID%>').value-0; if(aantal > 1) aantal -=1; calculateAmount(aantal); } function calculateAmount(aantal) { var prijs = document.getElementById('<%=lblPriceBestel.ClientID%>').innerHTML -0; var totaal = 0; if(aantal < 2) { totaal = prijs * aantal; document.getElementById('<%=lblKorting.ClientID%>').innerHTML = ""; } else if(aantal >= 2 && aantal < 5) { totaal = (prijs * aantal)*0.95; document.getElementById('<%=lblKorting.ClientID%>').innerHTML = "-5%"; } else if(aantal >= 5) { totaal = (prijs * aantal)*0.90; document.getElementById('<%=lblKorting.ClientID%>').innerHTML = "-10%"; } document.getElementById('<%=lblAmount.ClientID%>').innerHTML = totaal; } C# private OrderBO bestelling; protected void btnBestel_Click1(object sender, EventArgs e) { bestelling = new OrderBO(); bestelling.Amount = Convert.ToInt32(lblAmount.Text); //<--- THIS IS "" in the debugger, but on the page 10 }

    Read the article

< Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >