w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Convert JavaScript collection declaration code to corresponding C# code
Without external librairies (and I don't know any for this kind of tasks), you can use Regex: var input = "var buyPrice=[[Date.UTC(2012,0,9),385.250000], [Date.UTC(2012,0,10),386.250000], [Date.UTC(2012,0,11),387.000000]];" var regex = @"[Date.UTC((?<year>d{4}),(?<month>d{1,2}),(?<day>d{1,2})),(?<price>d+(.d+)?)]"; var matches = Regex.Matches(input, regex) .OfType<Match>() .Select(m => new { Date = new DateTime( Int32.Parse(m.Groups["year"].Value), Int32.Parse(m.Groups["month"].Value) + 1, Int32.Parse(m.Groups["day"].Value) ),

Categories : C#

Access Parent Page Control in Child User Control
You will have something like this in tab control. <cc1:TabContainer ID="TabContainer1" runat="server"> <cc1:TabPanel ID="TabPanel1" runat="server"> <ContentTemplate> <asp:DropDownList id="dropdownlist1" runat="Server"/> </ContentTemplate> </cc1:TabPanel> So first you need to find tabPanel1 then find dropdownlist1 like following. TabContainer TabContainer1= (TabContainer)(this.Page.FindControl("TabContainer1"); if (TabContainer1!=null){ TabPanel TabPanel1= (TabPanel)(this.TabContainer1.FindControl("TabPanel1"); if(TabPanel1 !=null){ DropDownList dropdownlist1= (DropDownList)(this.TabPanel1.FindControl("dropdownlist1"); }}

Categories : C#

How to access the main page control values in user control
To retrieve, for example, a textbox defined in the aspx page from an ascx control contained in it you could try: Dim myTextBox As TextBox = Ctype(Me.Parent.FindControl("myTextBoxName"), TextBox) Note that the control you want to retrieve must have a runat="server" attribute otherwise it can not be seen server side. In your question you posted three controls without runat="server"; you could use instead: <asp:HiddenField ID="HiddenField1" runat="server" Value="1" /> <asp:HiddenField ID="HiddenField2" runat="server" Value="2" /> <asp:HiddenField ID="HiddenField3" runat="server" Value="3" /> In this case the above command would become: Dim myHiddenField As HiddenField = Ctype(Me.Parent.FindControl("myHiddenFieldName"), HiddenField)

Categories : Asp Net

Retrieving ascx control value from a callback registered on master page. Control added to Repeater's PlaceHolder during OnItemCreated
I'm not sure what changed, maybe it was taking the break to rubber duck debug using all of the above. I've gone back and tried tweaking some of the things I had before (order of insertion, which call to use, etc) to see if they make a difference, but either way, the Control is now being persisted in the ViewState properly with the above code. It is available on postback from the master page call so long as the following is added (bullet #1 of what I tried before): protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); RefreshOptions(); } Earlier, savedState was only showing the List<int> added to it to maintain selected options. At some point in tweaking and debugging, I saw that the controls I created were now in the

Categories : C#

Technique to enable smooth page changing and prevent the browser redrawing for each page load
Well, although ASP.NET implements AJAX, and partial change of pages (through updatepanels for example) there's always a postback to the server with everything you do in .NET. Basically, there's always that "blank screen", but you probably don't see it in some cases, when the server answers quickly or you browser treats the HTML quicker for any reason. The only possibility I know to avoid full postbacks is to get out of the .NET logic and do AJAX request yourself by writing client code only. But this possibly comes with other problems (like the controls you may add this way not being "known" by your server code, for example).

Categories : HTML

How do I prevent the control box getting focus when I press Alt?
After the Alt gesture has been released, programmatically force your control to have focus by calling Control.Focus(). Why is this hack acceptable? Because this behavior is restricted to instances when your control has focus and the gesture is successfully processed.

Categories : C#

PHP array declaration breaking page
Looks like the server does not have PHP installed, is not configured correctly, or your file extension is wrong. In your browser, if you do View->Source, you'll see the full PHP code. The reason you only see part of it on the rendered view is because the browser treats the < and > within the code as HTML tags.

Categories : PHP

Is the XAML Declaration and Code Behind Necessary for WPF Animations?
Not sure what you are referring to exactly, but they probably just showed how to do the same animation in either language, only one is required. In general almost everything you can do in XAML can be done in code, often XAML is preferable because it's declarative and nicely structured.

Categories : C#

Prevent User Control from being resized during runtime
couple of things to check: do you use docking? - it will resize following parent control if yes do you use anchor? - it sometimes gives odd behavior too some controls have AutoSize property, did you set it true or is it by default true? some controls have AutoWidthInLayoutControl, did you set it true or is it by default true? another try, some controls do have Maximum and Minimum size, set these values to your desired if necessary.

Categories : Vb.Net

How to prevent the enter button from clicking a control in asp.net?
If it's WebForms, you could use something like onkeydown = "return (event.keyCode!=13);" in your asp:TextBox. Full example: <asp:TextBox ID="TextBox1" runat="server" onkeydown="return (event.keyCode!=13);"> This answer is coming from: disabling default button or enter key in c#

Categories : Asp Net

Any tool to find declaration of IDs in Python code?
Check out the inspect module. Particularly, inspect.getsourcelines() and inspect.getsourcefile().

Categories : Python

How to prevent a statement from breaking the control flow in Java
Encapsulate the problematic statement in a try catch block and handle the exception gracefully. Unhandled exception will make the control to return to the calling method for exception handling. Catching an exception will give you control to do the corrective actions and if logical then proceed with rest of the code. Put try/catch around your problematic statement s.executeBatch(), like this: else if (event.getSource()==btnSave) { btnAdd.doClick(); int a[]; try { a=s.executeBatch(); System.out.println ("dddddd"); } catch (Exception e) { System.out.prointln("Exception happened"); } btnRefresh.doClick(); con.commit(); s.clearBatch(); }

Categories : Java

How to prevent that a event in a control trigger when the form is closing
You will need to override the OnFormClosing method on the form and set a flag letting you know that the form is closing. Then, when validating, check that flag first. Be sure to set the flag before calling base. protected override void OnFormClosing(FormClosingEventArgs e) { _isClosing = true; base.OnFormClosing(e); }

Categories : C#

How to prevent Unity 3D's library to keep rebuilding itself with external version control?
As rolling files to an old version, then right back to the most current one triggers the rebuild, I can only imagine Unity is looking at timestamps on the files, at the very least. It's probably also looking at the tree - which files exist, etc., and it might be using hashes of content, or even tree structure. It would be interesting to - with Unity closed - copy your entire asset tree to a second location, in a manner that keeps timestamps, then checkout an old commit, then the current one again, then copy the copy back over it, again, keeping timestamps. Then open Unity and see if it wants to rebuild. If it does, I have no idea how it's figuring out that it needs to do this (storing where files reside on the disk, down at the block level?). If it works, it will only allow you that one

Categories : GIT

How to find control bounded in item template on master page from content page?
Try finding the control within the repeater object itself, like this: var hiddensubcategory2id = repsubcategory2.FindControl("hf3") as HiddenField; Note: You should always check to see if the result of a FindControl() is null or not, like this: if(hiddensubcategory2id != null) { // Do something with the control you found }

Categories : Asp Net

Pass master page control values on content page on page_load
Try this solution: Master page: <asp:DropDownList ID="ddlcategories" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlcategories_SelectedIndexChanged"> <asp:ListItem>One</asp:ListItem> <asp:ListItem>Two</asp:ListItem> </asp:DropDownList> Master page CS: public string SelectedValue { get { return ddlcategories.SelectedValue; } set { ddlcategories.SelectedValue= value; } } protected void ddlcategories_SelectedIndexChanged(object sender, EventArgs e) { SelectedValue = ddlcategories.SelectedValue; } Content Page markup: <%@ MasterType VirtualPath="~/Site1.Master" %> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> Content page CS. protected void Pag

Categories : C#

how to add an event property to a user control ascx accessible to the host page as a string in aspx page?
Please see the link below. I think it is quite near to yours. or you can search for event bubbling. Bubbling Events to Parent in ASP.NET Download sample code from here. It has two user controls and one aspx page with event bubbling implmentation https://skydrive.live.com/embed?cid=7A1FCBEC2CC6F643&resid=7A1FCBEC2CC6F643%212034&authkey=AANtP8lOxmwRJcQ

Categories : Asp Net

Integrating a Java based page key scrolling control in a page
What you need to do is to add a class tag (let's name it class="new") to every item on your list and handle keypress events to scroll to next item or the previous one, this code may help you : function scrollToNew () { scrollTop = $(window).scrollTop(); $('.new').each(function(i, h2){ // loop through article headings h2top = $(h2).offset().top; // get article heading top if (scrollTop < h2top) { // compare if document is below heading $.scrollTo(h2, 800); // scroll to in .8 of a second return false; // exit function } }); } jQuery(function () { $("#next").click(scrollToNew); $(document).keydown(function (evt) { if (evt.keyCode == 40) { // down arrow evt.preventDefault(); // prevents the usual scrolling behaviour scrollToNew(); // scr

Categories : Javascript

How to caputure page level events on a user control on that same page
If you are trying to pass a parent's button click event to a child, you can do it. In the User Control, make a method called HandleParentButtonClick(passing necessary parameters). In the parent's OnClick event, call the User Control's HandleParentButtonClick method.

Categories : C#

I have a gridview with a paging event. Everytime I hit a new page it makes me reload the file from the uploadfile control then it displays new page
We generally use a GridView Control to Display Data and also Perform Paging, Sorting, Editing, Deleting records. In each of these we have postback on the page. To avoid Postback during sorting and Paging, the following code can be used inside the GridView Control. If you have created a GridView and Bind the GridView using data source control, you can avoid postback during sorting and paging by setting EnableSortingAndPagingCallbacks' property of the GridView to True. Note : when you use the 'EnableSortingAndPagingCallbacks' property to true for avoid Postback, you cannot use Template Fields in the GridView. Example : <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"AllowSorting = "true" DataSourceID="SqlDataSource1" EnableSortingAndPagingCallbacks = "true">

Categories : C#

How to control what part of a UIView to update (iOS/Xamarin) - I need to prevent the screen from being fully erased
For the graph data, you should be using CoreGraphics directly to render the lines in your UIView subclass' drawRect: method. Make sure that method only redraws the data that overlaps with the CGRect argument. The method setNeedsDisplay marks the entire UIView as needing a redraw, so instead of using that when your graph data changes, you should use the UIView's method setNeedsDisplayInRect: to indicate that there's new data in that region of the UIView that will call drawRect: to be called, which will only redraw that portion (if you've implemented it right). Regarding the background grid, you can render the grid to a UIImage then display that UIImage behind your view that draws the graph. You'll want to look at the documentation for UIGraphicsBeginImageContext, CALayer renderInContext:,

Categories : IOS

Why does empty variable declaration of type show compile error but not for null declaration?
Because s2 is not initialized and s1 is initialized with null For Que 1: You are performing trim() Operation on null actually, so it will throw NPE (NullPointerException) as it should be. For Que 2: See §4.12.5 of the JLS for a very detailed explanation: A local variable must be explicitly given a value before it is used, by either initialization or assignment, in a way that can be verified by the compiler using the rules for definite assignment.

Categories : Java

System.Xml.XmlException: Unexpected XML declaration. The XML declaration must be the first
Make sure your <?xml tag is the first thing in the document (and that it doesn't have anything before that, this includes whitespace). You can have <?xml only once per document, so if you have a large chunk of XML and you have this tag repeated somewhere down the lines your document won't be valid.

Categories : C#

C# - find page control in the page
This is because you're not getting all the controls in your page. You'd have to get controls recursively. Here's an extension method: public static class ControlExtensions { public static List<Control> GetChildrenRecursive(this Control control) { var result = new List<Control>(); foreach (Control childControl in control.Controls) { result.Add(childControl); if (childControl.Controls.Count > 0) { result.AddRange(GetChildrenRecursive(childControl)); } } return result; } } Now you can rewrite your code as follows: foreach (Control ctrl in this.Page.GetChildrenRecursive()) { // Your button element is accessible now. }

Categories : C#

How to prevent div from scrolling out of page
OK, using the keywords suggested by Mike Brant up in the comments, my Google search produced some good results. It appears that the functionality I was after is called sticky div, or sticky menu, sticky footer, or likewise. By looking at the code of those javascripts I was able to understand the concept behind it. Now, it's time to play with it and adjust to my particular needs.

Categories : Javascript

Is it possible to prevent a page being loaded using XHR?
I think your best bet would be checking the X-Requested-With header for a value of XMLHttpRequest as most clientside frameworks/libraries send that header when accessing your site with XHR. However, doing so will not block every attempt to load the page with XHR as it is not a mandatory XHR header and can be spoofed. I don't see how setting a CSP header would help in that case as it should protect your app/site from accessing malign content instead of protecting your app/site from being accessed. "Content Security Policy is a declarative policy that lets the authors (or server administrators) of a web application inform the client about the sources from which the application expects to load resources" Source: Content Security Policy 1.1 On a sidenote: If your JavaScript remove

Categories : Javascript

Prevent page refresh in ASP.NET
My answer is appropriate only for ASP:Button, not the button control you are working with. Given the choice, I'd switch to ASP:Button. You're looking for OnClientClick. If you put your JavaScript code there, it will kill the PostBack before it can hit the server. On the other hand, if you're looking to execute server code without a PostBack, that's impossible. The PostBack is what triggers the server to act.

Categories : Asp Net

Prevent access to thank you page?
you just need to create session in the form and you need to check, whether the session was set with isset function. If not, use die at the beginning. if (!isset($_SESSION['thank'])) die;

Categories : PHP

Will my code prevent SQL injection
You need to use prepared statements for any queries that require user input. This sends the query and the parameters seperately and acts as a layer of security to catch any malicious input. In PDO: $stmt = $pdo->prepare("SELECT * FROM fbusers WHERE user_id = :var"); $stmt->execute(array(':var'=>$var)); In mysqli: $stmt = $dbConnection->prepare('SELECT * FROM fbusers WHERE user_id = ?'); $stmt->bind_param('s', $var); $stmt->execute(); Maybe this post would help.

Categories : Mysql

How to prevent html page from refreshing
Seems like there is only one way to prevent this , onbeforeunload catching , <script> window.onbeforeunload = function() { return 'You have unsaved canvases!'; } </script> Try to refresh now: http://jsfiddle.net/xNSVm/2/ Reference: https://developer.mozilla.org/en-US/docs/Web/API/window.onbeforeunload

Categories : Javascript

How to prevent a page from resubmitting? in grails 2.2.0
Its hard to infer the cause of the error with what you have posted. However, you asked about how to prevent a page from resubmitting in Grails. Take a look at documentation. Grails has a build in support for that. Basically you define a form with a token and using withForm you will check if the token still is valid or not. <g:form useToken="true" ...> / withForm { // good request }.invalidToken { // bad request }

Categories : Grails

jquery click prevent going to top of page
Add an e (for the event parameter) to your click function. $('#videoconner').click(function (e) { e.preventDefault(); $(this).replaceWith('<iframe width="280" height="164" src="http://www.youtube.com/embed/6kR2n4344UCAU?autoplay=1&cc_load_policy=1&rel=0" frameborder="0" allowfullscreen></iframe>'); });

Categories : Jquery

How to prevent spam inputs on a web page?
Perhaps you can use jQuery to disable the button. $('#myButton').click(function(){ $('#myButton').attr("disabled", "disabled"); setTimeout(unlockButton, 1000); }); function unlockButton(){ $('#myButton').removeAttr('disabled'); } Like so: http://jsfiddle.net/D3zLf/

Categories : Javascript

It is possible to prevent a page load using javascript
At a quick glance I can see nothing wrong with your code, I am assuming the problem lies with the page you are calling, it should only return the needed data as you are just capturing what it throws.

Categories : Javascript

How to prevent iteration over same attributes on jsp page
If you write too much content using c:forEach then it will take time. From your example I found the complexity is n cube. Basically on the server side the html is generated and it is rendered on client side after server send it. As for example if you write 1000 row in the page then a huge html page is generated on the buffer. If buffer size is large it takes time to flush it. Most important point is that response time depends on how much data you are writing So, for performance improvement you can do the following Try to avoid n cube complexity. Do , something in the DAO so that in the jsp page you can write on order n complexity. Do not render full data at a time. Instead render partial data and use pagination to fetch more.

Categories : Forms

Prevent direct access to some page in JSF
I don't think you can do all that from JSF. Your obvious alternative is to use Javascript. I never herd a concept of disabling Bookmark option in Browser using Javascript. However you can always disable the address field if you open the page in new Window.

Categories : JSF

Prevent a link to reload page
It's not the element that need a .preventDefault(), its the click event. Try this: $('nav.menu a').click(function (event) { event.preventDefault(); // or use return false; }); I don't recommend to use the href as selector though, better to give it an id or name. From MDN, about .preventDefault(): Cancels the event if it is cancelable, without stopping further propagation of the event. You can read more here: MDN: event.preventDefault() jQuery: Selectors There is a CSS way, using pointer-events. So by using in the CSS pointer-events: none; all click will be ignored. This is a "recent" alternative and suported in IE11+, Firefox 3.6+, Chrome 2.0+, Safari 4+. Example

Categories : Javascript

How do I prevent AJAX from sending me to the top of the page?
I doubt it is executing the default form submit behavior. Prevent it byt using the preventDefault method. $(function(){ $('#signup-form').submit(function(e) { e.preventDefault(); //your existing code goes here }); });

Categories : PHP

prevent full page scrolling iOS
While you're not hitting the edges of your div's content, you need to allow the native touchmove event to work on that element (so it can scroll), but you're going to want to stop the event from bubbling up the DOM so that it doesn't trigger scrolling on the page body. When you hit the boundary of your element, you need to prevent the native momentum scrolling entirely. The code I use for this is as follows (apologies to the original author, this is adapted from a tutorial on this topic I found somewhere on the internet in the past... Can't seem to find the URL now though): where elem is your DOM node elem.addEventListener('touchstart', function(event){ this.allowUp = (this.scrollTop > 0); this.allowDown = (this.scrollTop < this.scrollHeight - this.clientHeight); t

Categories : Javascript

how can i prevent code behind method call in asp.net
Use one on the client side. This will prevent double clicks. $("#button").one("click", function() { // validate the form. // if form is valid, submit form }); An alternative solution is to have a boolean flag. var submitting = false; $("#button").click(function() { if (!submitting) { submitting = true; if (formIsValid) { submitting = false; $("#form").submit(); } else { submitting = false; } } });

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.