[Solved] Why does try catch not catch Sql syntax error

The catch in the above code does actually catch the exception. On the exception set the Select Command to something default that is sure to work ie. SELECT * FROM Database And Execute the select. The reason for this is when the page does a post back it tries to execute the select statement that … Read more

[Solved] How to login external web site from asp.net web page? [closed]

Hopefully, most web sites will prevent this type of thing. It is considered a cross site request forgery. You can read more about it here and if you still want to do it, at least you will know what you are getting into. Be safe. http://en.wikipedia.org/wiki/Cross-site_request_forgery 1 solved How to login external web site from … Read more

[Solved] For condition running only once when calling JS File

What @Lloyd said is correct, the + i is necessary to make unique pairs. Try this: for (int i = 0; i <= 2; i++) { Page.ClientScript.RegisterStartupScript(GetType(), “a”+ i, “foo(‘hello’);”, true); } You were missing the semicolon at the end of the javascript function. This is what was being generated with what @Lloyd suggested <script … Read more

[Solved] Linq – cast anonymous type to concrete type

Simply create instances of the concrete type (there is no requirement to use an anonymous types in LINQ): var suppliers = SupplierView.Select() .GroupBy(x => x.Name.Substring(0, 1).ToUpper(), (alphanumeric, suppliers) => new AlphanumericSuppliers // concrete { Alphanumeric = alphanumeric, Suppliers = suppliers.OrderBy(x => x.Name).ToList() // * }) .OrderBy(x => x.Alphanumeric); *As mentioned in comments, either change Suppliers … Read more

[Solved] Range Validation in asp.net [closed]

For making field MANDATORY: Use RequiredFieldValidator: <asp:TextBox ID=”txtName” runat=”server”></asp:TextBox> <asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ControlToValidate=”txtName” ErrorMessage=”Input Country!” EnableClientScript=”true” SetFocusOnError=”true” Text=”*”> </asp:RequiredFieldValidator> For Validating Range of Number in TextBox use RangeValidator: <asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox> <asp:RangeValidator ID=”RangeValidator1″ runat=”server” ControlToValidate=”TextBox1″ MaximumValue=”200″ MinimumValue=”100″ Type=”Integer” ErrorMessage=”Please input between 100 to 200.”> </asp:RangeValidator> Read more about Validations Here Hope this helps you! 2 … Read more

[Solved] How to do the same in JavaScript? [closed]

If you want Vanilla JavaScript solution you can try this: function startCalc() { var root = document.documentElement || document.body; root.addEventListener(‘blur’, function(e) { var node = e.target; if (node.nodeName == ‘input’ && node.getAttribute(‘type’) == ‘text’) { var imekontrolebase = node.getAttribute(‘id’); var ime = imekontrolebase.substr(12, imekontrolebase.length); var n = ime.indexOf(“_”); var red = ime.substr(n+1); var imekol1 = … Read more

[Solved] Query string is too long

maxRequestLength is for file uploads. Try this instead under the system.web node <httpRuntime maxUrlLength=”1000″ maxQueryStringLength=”1000″ /> 1 solved Query string is too long

[Solved] How to send mail using C# with html format [closed]

Setting isBodyHtml to true allows you to use HTML tags in the message body: SmtpClient sc = new SmtpClient(“mail address”); MailMessage msg = null; try { msg = new MailMessage(“[email protected]”, “[email protected]”, “Message from PSSP System”, “This email sent by the PSSP system<br />” + “<b>this is bold text!</b>”); msg.IsBodyHtml = true; sc.Send(msg); } catch (Exception … Read more

[Solved] How to Calculate a Discount In LINQ [closed]

Firstly this code is really starting to need a ViewModel or some other construct that would enable you to decouple your business logic from your UI. Having said that, the quick and dirty answer to get you going, would be to implement an interim linq query and then build your results from that // From … Read more

[Solved] How to Map my input data [closed]

Code string str = “VALVE,GATE,SH_NAME:VLV,GATE,VLV_NOM_SIZE:4-1/16IN”; string[] Rows = str.Split(‘,’); dataGridView1.Columns.Add(“Column1”, “Column1”); dataGridView1.Columns.Add(“Column2”, “Column2”); foreach (string AddRow in Rows) { string[] Row = AddRow.Split(‘:’); dataGridView1.Rows.Add(Row); } 2 solved How to Map my input data [closed]

[Solved] Can’t use nested variable

To use the variable outside the block you need to declare it outside the block. As the variable has to have a value even if you don’t run the code in the block, you either have to set an initial value: string test = null; if (condition) { test = “success”; } or use an … Read more