问:
clicking button within UITableview cell gives wrong result while search
Within the cells of a tableview I have a button. The button basically opens the file that the cell refers to. This is working fine while the search is not on. But while the search is on, I can't seem to get the correct row within the search results array.
This is what I have tried so far:
in the cellForRowAtIndexPath I tagged the button.

```<code>myDownloadsBtn = (UIButton *) [cell viewWithTag:106];
</code>```

the action is set as follows:

```<code>[myDownloadsBtn addTarget:self action: @selector(downloadClicked:event:) forControlEvents:UIControlEventTouchUpInside];
</code>```

then in downloadClicked I have the following

```<code>    NSSet *touches = [event allTouches];
    UITouch *touch = [touches anyObject];
    NSString *todoRow;
    CGPoint currentTouchPosition = [touch locationInView:self->tableview];
    NSIndexPath *indexPath = [self->tableview indexPathForRowAtPoint: currentTouchPosition];
</code>```

but it gives me the indexPath of the VISIBLE current position, not the position of the row within the search results array.

Also, my delegate method ofdidSelectRowAtIndexPath works fine with and without the search. It is just for buttons within the cells.

I have found this question, but there is no answer:
how to get selected tableview button value while search in iOS.

the other questions deal with how to know the actual cell selected when searching, but that is not my problem.

Thank you.

答:
Yo can assign tag to button as

```<code>[myDownloadsBtn setTag:indexPath.row];
</code>```

and in your downloadClicked action access the tag hence the index of the row that is being touched / button clicked

```<code>-(IBAction)myDownloadsBtn:(id)sender
 {
   UIButton *tappedBtn = (UIButton*)sender;
   Nslog("%d",tappedBtn.tag); // Get tag hence indexpath of tableview in which button is clicked.
  }
</code>```

You need to reload  table data with search results array.

Hope it helps. Happy Coding!!

Body:
Within the cells of a tableview I have a button. The button basically opens the file that the cell refers to. This is working fine while the search is not on. But while the search is on, I can't seem to get the correct row within the search results array.
This is what I have tried so far:
in the cellForRowAtIndexPath I tagged the button.

myDownloadsBtn = (UIButton *) [cell viewWithTag:106];

the action is set as follows:

[myDownloadsBtn addTarget:self action: @selector(downloadClicked:event:) forControlEvents:UIControlEventTouchUpInside];

then in downloadClicked I have the following

    NSSet *touches = [event allTouches];
    UITouch *touch = [touches anyObject];
    NSString *todoRow;
    CGPoint currentTouchPosition = [touch locationInView:self->tableview];
    NSIndexPath *indexPath = [self->tableview indexPathForRowAtPoint: currentTouchPosition];

but it gives me the indexPath of the VISIBLE current position, not the position of the row within the search results array.

Also, my delegate method ofdidSelectRowAtIndexPath works fine with and without the search. It is just for buttons within the cells.

I have found this question, but there is no answer:
how to get selected tableview button value while search in iOS.

the other questions deal with how to know the actual cell selected when searching, but that is not my problem.

Thank you.

Body:
Yo can assign tag to button as

[myDownloadsBtn setTag:indexPath.row];

and in your downloadClicked action access the tag hence the index of the row that is being touched / button clicked

-(IBAction)myDownloadsBtn:(id)sender
 {
   UIButton *tappedBtn = (UIButton*)sender;
   Nslog("%d",tappedBtn.tag); // Get tag hence indexpath of tableview in which button is clicked.
  }

You need to reload  table data with search results array.

Hope it helps. Happy Coding!!


来源: stackexchange

问:
How can I add a keyboard shortcut to an existing JavaScript Function?
Here is my code:

```<code>function pauseSound() {
    var pauseSound = document.getElementById("backgroundMusic");
    pauseSound.pause();
}
</code>```

I would like to add a keyboard shortcut to this code, how can I do this so that the function can also be executed when a button is clicked too?

Tried to add an else if statement but it doesn't work, any ideas?

```<code>function doc_keyUp(e) {
    if (e.ctrlKey && e.keyCode == 88) {
        pauseSound();
    }

    else if (e.ctrlKey && e.keyCode == 84) {
        playSound();
    }
}
</code>```

答:
This worked for me</p>

```<code>document.onkeyup=function(e){
  var e = e || window.event;
  if(e.which == 37) {
    $("#prev").click()
  }else if(e.which == 39){
    $("#next").click()
  }
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Here is my code:

function pauseSound() {
    var pauseSound = document.getElementById("backgroundMusic");
    pauseSound.pause();
}

I would like to add a keyboard shortcut to this code, how can I do this so that the function can also be executed when a button is clicked too?

Tried to add an else if statement but it doesn't work, any ideas?

function doc_keyUp(e) {
    if (e.ctrlKey && e.keyCode == 88) {
        pauseSound();
    }

    else if (e.ctrlKey && e.keyCode == 84) {
        playSound();
    }
}

Body:
This worked for me

document.onkeyup=function(e){
  var e = e || window.event;
  if(e.which == 37) {
    $("#prev").click()
  }else if(e.which == 39){
    $("#next").click()
  }
}

ContentLicense: CC BY-SA 3.0


问:
Store MSMQ queue in database
I'm new to MSMQ for .NET and have a question.

For my system I want to use MSMQ for queuing some system requests, but a customer wants to keep all information in database. I wonder is there any way to store MSMQ messages in database?

Currently I see the only way to create some record in database and put record id to queue.

答:
Yes, you would need to read the records from your queue and store in a database. Typically you might do this using a Windows service. </p>

<p>Typically, you only need to use MSMQ if there might be intermittant networking connectivity between two locations or you think the number of requests exceeds what the database can handle in one go. Otherwise, just store straight in the database. </p>

ContentLicense: CC BY-SA 2.5

Title: Store MSMQ queue in database

Body:
Yes, you would need to read the records from your queue and store in a database. Typically you might do this using a Windows service.

Typically, you only need to use MSMQ if there might be intermittant networking connectivity between two locations or you think the number of requests exceeds what the database can handle in one go. Otherwise, just store straight in the database.


问:
How can I merge several XML-documents into one without namespace accumulation?
I have several SVG-segments in a table stored as xml-document.
Now I need to select all elements from that table, and merge them into one XML-document.

This is the T-SQL code I have:

```<code>declare @xml table (xmldocument xml)
insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
  <path id="789" data-objid="0000X2"></path>
</svg>'

insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
  <admin>
  <g>
  <path></path>
  <path data-objid="0000X1"></path>
  <path id="123" data-objid="0000X2"></path>
  <path id="456" data-objid="0000X3"></path>
  </g>
  </admin>

    <g>
    <path></path>
    <path data-objid="0000X1"></path>
  <path id="789" data-objid="0000X2"></path>
  <path id="abc" data-objid="0000X3"></path>
  </g>
</svg>'

insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
    <path></path>
</svg>'

insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
  <path id="abc" data-objid="0000X3"></path>
</svg>'

--;WITH XMLNAMESPACES ('http://www.w3.org/2000/svg' AS svg)
;WITH XMLNAMESPACES (default 'http://www.w3.org/2000/svg')
--SELECT
    --(
        SELECT
             --xmldocument

            --,c.p.value('.', 'nvarchar(MAX)')
            c.p.query('declare default element namespace "http://www.w3.org/2000/svg";.')
        FROM @xml AS t

        OUTER APPLY t.xmldocument.nodes('/svg//*') AS c(p)

        FOR XML PATH(''), root('svg')
--  ) AS merged
</code>```

But this produces

```<code><svg xmlns="http://www.w3.org/2000/svg">
  <path xmlns="http://www.w3.org/2000/svg" id="789" data-objid="0000X2" />
  <admin xmlns="http://www.w3.org/2000/svg">
    <g>
      <path />
      <path data-objid="0000X1" />
      <path id="123" data-objid="0000X2" />
      <path id="456" data-objid="0000X3" />
    </g>
  </admin>
  <g xmlns="http://www.w3.org/2000/svg">
    <path />
    <path data-objid="0000X1" />
    <path id="123" data-objid="0000X2" />
    <path id="456" data-objid="0000X3" />
  </g>
  <path xmlns="http://www.w3.org/2000/svg" />
  <path xmlns="http://www.w3.org/2000/svg" data-objid="0000X1" />
  <path xmlns="http://www.w3.org/2000/svg" id="123" data-objid="0000X2" />
  <path xmlns="http://www.w3.org/2000/svg" id="456" data-objid="0000X3" />
  <g xmlns="http://www.w3.org/2000/svg">
    <path />
    <path data-objid="0000X1" />
    <path id="789" data-objid="0000X2" />
    <path id="abc" data-objid="0000X3" />
  </g>
  <path xmlns="http://www.w3.org/2000/svg" />
  <path xmlns="http://www.w3.org/2000/svg" data-objid="0000X1" />
  <path xmlns="http://www.w3.org/2000/svg" id="789" data-objid="0000X2" />
  <path xmlns="http://www.w3.org/2000/svg" id="abc" data-objid="0000X3" />
  <path xmlns="http://www.w3.org/2000/svg" />
  <path xmlns="http://www.w3.org/2000/svg" id="abc" data-objid="0000X3" />
</svg>
</code>```

instead of

```<code><svg xmlns="http://www.w3.org/2000/svg">
  <path id="789" data-objid="0000X2" />
  <admin>
    <g>
      <path />
      <path data-objid="0000X1" />
      <path id="123" data-objid="0000X2" />
      <path id="456" data-objid="0000X3" />
    </g>
  </admin>
  <g>
    <path />
    <path data-objid="0000X1" />
    <path id="123" data-objid="0000X2" />
    <path id="456" data-objid="0000X3" />
  </g>
  <path />
  <path data-objid="0000X1" />
  <path id="123" data-objid="0000X2" />
  <path id="456" data-objid="0000X3" />
  <g>
    <path />
    <path data-objid="0000X1" />
    <path id="789" data-objid="0000X2" />
    <path id="abc" data-objid="0000X3" />
  </g>
  <path />
  <path data-objid="0000X1" />
  <path id="789" data-objid="0000X2" />
  <path id="abc" data-objid="0000X3" />
  <path />
  <path id="abc" data-objid="0000X3" />
</svg>
</code>```

What am I missing ? What do I do wrong ?

How to correct this without having to cast to varchar and then do a search-and-replace on "xmlns=..." ?

答:
First of all: The repeated namespaces are not wrong in any way, just annoying and bloating the size of your result...

Unfortunately there is no way to get rid of them in a clean way. Your idea of casting to text and do this on string level is not that bad, if you really need this (but be aware, that casting must go to NVARCHAR and the re-cast to XML can change your XML stucturally (attribute order, CDATA-sections...). Try this:

Short approach

...if you really do not need anything else, than the namespace in the first root <svg>...

```<code>DECLARE @NewXML NVARCHAR(MAX)=
(
    SELECT t.xmldocument.query('declare default element namespace "http://www.w3.org/2000/svg";svg/*')
    FROM @xml AS t
    FOR XML PATH('')
);
SELECT CAST(N'<svg xmlns="http://www.w3.org/2000/svg">'
          + REPLACE(@NewXML,' xmlns="http://www.w3.org/2000/svg"','')
          + N'</svg>' AS XML);
</code>```

More flexible approach

You might try this:

```<code>DECLARE @NewXML XML=
(
    SELECT t.xmldocument.query('declare default element namespace "http://www.w3.org/2000/svg";svg/*')
    FROM @xml AS t
    FOR XML PATH(''),TYPE
);
SET @NewXML =CAST(REPLACE(CAST(@NewXML AS NVARCHAR(MAX)),' xmlns="http://www.w3.org/2000/svg"','') AS XML);
</code>```

--You need to repeat the CAST and REPLACE, otherwise you'd get a lot of xmlns="" defining an empty default namespace for the inner nodes, which was wrong...

```<code>WITH XMLNAMESPACES (DEFAULT 'http://www.w3.org/2000/svg')
SELECT @NewXML=CAST(REPLACE(CAST((SELECT @NewXML FOR XML PATH('svg'),TYPE) AS NVARCHAR(MAX)),' xmlns=""','') AS XML);
SELECT @NewXML;
</code>```

You might use STUFF() to introduce the namespace on string level:

(Don't use WITH XMLNAMESPACES here...

```<code>SELECT @NewXML=CAST(STUFF(CAST((SELECT @NewXML FOR XML PATH('svg'),TYPE) AS NVARCHAR(MAX)),5,0,' xmlns="http://www.w3.org/2000/svg" ') AS XML);
SELECT @NewXML;
</code>```

The result in all cases

```<code><svg xmlns="http://www.w3.org/2000/svg">
  <path id="789" data-objid="0000X2" />
  <admin>
    <g>
      <path />
      <path data-objid="0000X1" />
      <path id="123" data-objid="0000X2" />
      <path id="456" data-objid="0000X3" />
    </g>
  </admin>
  <g>
    <path />
    <path data-objid="0000X1" />
    <path id="789" data-objid="0000X2" />
    <path id="abc" data-objid="0000X3" />
  </g>
  <path />
  <path id="abc" data-objid="0000X3" />
</svg>
</code>```

Body:
I have several SVG-segments in a table stored as xml-document.
Now I need to select all elements from that table, and merge them into one XML-document.

This is the T-SQL code I have:

declare @xml table (xmldocument xml)
insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
  <path id="789" data-objid="0000X2"></path>
</svg>'

insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
  <admin>
  <g>
  <path></path>
  <path data-objid="0000X1"></path>
  <path id="123" data-objid="0000X2"></path>
  <path id="456" data-objid="0000X3"></path>
  </g>
  </admin>

    <g>
    <path></path>
    <path data-objid="0000X1"></path>
  <path id="789" data-objid="0000X2"></path>
  <path id="abc" data-objid="0000X3"></path>
  </g>
</svg>'

insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
    <path></path>
</svg>'

insert @xml select '
<svg xmlns="http://www.w3.org/2000/svg" otherattrib="x">
  <path id="abc" data-objid="0000X3"></path>
</svg>'

--;WITH XMLNAMESPACES ('http://www.w3.org/2000/svg' AS svg)
;WITH XMLNAMESPACES (default 'http://www.w3.org/2000/svg')
--SELECT
    --(
        SELECT
             --xmldocument

            --,c.p.value('.', 'nvarchar(MAX)')
            c.p.query('declare default element namespace "http://www.w3.org/2000/svg";.')
        FROM @xml AS t

        OUTER APPLY t.xmldocument.nodes('/svg//*') AS c(p)

        FOR XML PATH(''), root('svg')
--  ) AS merged

But this produces

<svg xmlns="http://www.w3.org/2000/svg">
  <path xmlns="http://www.w3.org/2000/svg" id="789" data-objid="0000X2" />
  <admin xmlns="http://www.w3.org/2000/svg">
    <g>
      <path />
      <path data-objid="0000X1" />
      <path id="123" data-objid="0000X2" />
      <path id="456" data-objid="0000X3" />
    </g>
  </admin>
  <g xmlns="http://www.w3.org/2000/svg">
    <path />
    <path data-objid="0000X1" />
    <path id="123" data-objid="0000X2" />
    <path id="456" data-objid="0000X3" />
  </g>
  <path xmlns="http://www.w3.org/2000/svg" />
  <path xmlns="http://www.w3.org/2000/svg" data-objid="0000X1" />
  <path xmlns="http://www.w3.org/2000/svg" id="123" data-objid="0000X2" />
  <path xmlns="http://www.w3.org/2000/svg" id="456" data-objid="0000X3" />
  <g xmlns="http://www.w3.org/2000/svg">
    <path />
    <path data-objid="0000X1" />
    <path id="789" data-objid="0000X2" />
    <path id="abc" data-objid="0000X3" />
  </g>
  <path xmlns="http://www.w3.org/2000/svg" />
  <path xmlns="http://www.w3.org/2000/svg" data-objid="0000X1" />
  <path xmlns="http://www.w3.org/2000/svg" id="789" data-objid="0000X2" />
  <path xmlns="http://www.w3.org/2000/svg" id="abc" data-objid="0000X3" />
  <path xmlns="http://www.w3.org/2000/svg" />
  <path xmlns="http://www.w3.org/2000/svg" id="abc" data-objid="0000X3" />
</svg>

instead of

<svg xmlns="http://www.w3.org/2000/svg">
  <path id="789" data-objid="0000X2" />
  <admin>
    <g>
      <path />
      <path data-objid="0000X1" />
      <path id="123" data-objid="0000X2" />
      <path id="456" data-objid="0000X3" />
    </g>
  </admin>
  <g>
    <path />
    <path data-objid="0000X1" />
    <path id="123" data-objid="0000X2" />
    <path id="456" data-objid="0000X3" />
  </g>
  <path />
  <path data-objid="0000X1" />
  <path id="123" data-objid="0000X2" />
  <path id="456" data-objid="0000X3" />
  <g>
    <path />
    <path data-objid="0000X1" />
    <path id="789" data-objid="0000X2" />
    <path id="abc" data-objid="0000X3" />
  </g>
  <path />
  <path data-objid="0000X1" />
  <path id="789" data-objid="0000X2" />
  <path id="abc" data-objid="0000X3" />
  <path />
  <path id="abc" data-objid="0000X3" />
</svg>

What am I missing ? What do I do wrong ?

How to correct this without having to cast to varchar and then do a search-and-replace on "xmlns=..." ?

Body:
First of all: The repeated namespaces are not wrong in any way, just annoying and bloating the size of your result...

Unfortunately there is no way to get rid of them in a clean way. Your idea of casting to text and do this on string level is not that bad, if you really need this (but be aware, that casting must go to NVARCHAR and the re-cast to XML can change your XML stucturally (attribute order, CDATA-sections...). Try this:

Short approach

...if you really do not need anything else, than the namespace in the first root <svg>...

DECLARE @NewXML NVARCHAR(MAX)=
(
    SELECT t.xmldocument.query('declare default element namespace "http://www.w3.org/2000/svg";svg/*')
    FROM @xml AS t
    FOR XML PATH('')
);
SELECT CAST(N'<svg xmlns="http://www.w3.org/2000/svg">'
          + REPLACE(@NewXML,' xmlns="http://www.w3.org/2000/svg"','')
          + N'</svg>' AS XML);

More flexible approach

You might try this:

DECLARE @NewXML XML=
(
    SELECT t.xmldocument.query('declare default element namespace "http://www.w3.org/2000/svg";svg/*')
    FROM @xml AS t
    FOR XML PATH(''),TYPE
);
SET @NewXML =CAST(REPLACE(CAST(@NewXML AS NVARCHAR(MAX)),' xmlns="http://www.w3.org/2000/svg"','') AS XML);

--You need to repeat the CAST and REPLACE, otherwise you'd get a lot of xmlns="" defining an empty default namespace for the inner nodes, which was wrong...

WITH XMLNAMESPACES (DEFAULT 'http://www.w3.org/2000/svg')
SELECT @NewXML=CAST(REPLACE(CAST((SELECT @NewXML FOR XML PATH('svg'),TYPE) AS NVARCHAR(MAX)),' xmlns=""','') AS XML);
SELECT @NewXML;

You might use STUFF() to introduce the namespace on string level:

(Don't use WITH XMLNAMESPACES here...

SELECT @NewXML=CAST(STUFF(CAST((SELECT @NewXML FOR XML PATH('svg'),TYPE) AS NVARCHAR(MAX)),5,0,' xmlns="http://www.w3.org/2000/svg" ') AS XML);
SELECT @NewXML;

The result in all cases

<svg xmlns="http://www.w3.org/2000/svg">
  <path id="789" data-objid="0000X2" />
  <admin>
    <g>
      <path />
      <path data-objid="0000X1" />
      <path id="123" data-objid="0000X2" />
      <path id="456" data-objid="0000X3" />
    </g>
  </admin>
  <g>
    <path />
    <path data-objid="0000X1" />
    <path id="789" data-objid="0000X2" />
    <path id="abc" data-objid="0000X3" />
  </g>
  <path />
  <path id="abc" data-objid="0000X3" />
</svg>


问:
How To print a long string into multiple pages in C#
I'm trying to print a very long string using code below but it prints the whole text only in one page. Is there any easy way to print it correctly?

```<code>string text="the text has like 1000 words";

System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();

p.PrintPage += delegate (object sender1, System.Drawing.Printing.PrintPageEventArgs e1)
{
    e1.Graphics.DrawString(text, new System.Drawing.Font("Times New Roman", 12), new System.Drawing.SolidBrush(System.Drawing.Color.Black), new System.Drawing.RectangleF(50, 50, p.DefaultPageSettings.PrintableArea.Width - 50, p.DefaultPageSettings.PrintableArea.Height - 50));

};
try
{
    p.Print();
}
catch (Exception ex)
{
    throw new Exception("Exception Occured While Printing", ex);
}
</code>```

I tried to solve it with this article but the method stuck in some loop that I don't know how to fix.

答:
You have to keep in mind that PrintDocument will raise the event PrintPage as long as you tell it there are more pages. It is your task to keep track of what is printed, what needs to printed next and if you need another page or not.

There are several ways to accomplish that. I have chosen in this case to take the content of your text, check how much of it fits on the current page, DrawString that bit and then update my processing string, called remainingtext to be able to repeat for the next Page. The decision if a next page is needed is controlled by setting HasMorepages of the PrintEvent arguments instance to true or false when we're done.

Here is the code:

```<code>PrintDocument p = new PrintDocument();

var font = new Font("Times New Roman", 12);
var margins = p.DefaultPageSettings.Margins;
var layoutArea = new RectangleF(
    margins.Left,
    margins.Top,
    p.DefaultPageSettings.PrintableArea.Width - (margins.Left + margins.Right ),
    p.DefaultPageSettings.PrintableArea.Height - (margins.Top + margins.Bottom));
var layoutSize = layoutArea.Size;
layoutSize.Height = layoutSize.Height - font.GetHeight(); // keep lastline visible
var brush = new SolidBrush(Color.Black);

// what still needs to be printed
var remainingText = text;

p.PrintPage += delegate (object sender1, PrintPageEventArgs e1)
{
    int charsFitted, linesFilled;

    // measure how many characters will fit of the remaining text
    var realsize = e1.Graphics.MeasureString(
        remainingText,
        font,
        layoutSize,
        StringFormat.GenericDefault,
        out charsFitted,  // this will return what we need
        out linesFilled);

    // take from the remainingText what we're going to print on this page
    var fitsOnPage = remainingText.Substring(0, charsFitted);
    // keep what is not printed on this page
    remainingText = remainingText.Substring(charsFitted).Trim();

    // print what fits on the page
    e1.Graphics.DrawString(
        fitsOnPage,
        font,
        brush,
        layoutArea);

    // if there is still text left, tell the PrintDocument it needs to call
    // PrintPage again.
    e1.HasMorePages = remainingText.Length > 0;
};
p.Print();
</code>```

When I hookup an PrintPreviewControl this is the result:

Body:
I'm trying to print a very long string using code below but it prints the whole text only in one page. Is there any easy way to print it correctly?

string text="the text has like 1000 words";

System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();

p.PrintPage += delegate (object sender1, System.Drawing.Printing.PrintPageEventArgs e1)
{
    e1.Graphics.DrawString(text, new System.Drawing.Font("Times New Roman", 12), new System.Drawing.SolidBrush(System.Drawing.Color.Black), new System.Drawing.RectangleF(50, 50, p.DefaultPageSettings.PrintableArea.Width - 50, p.DefaultPageSettings.PrintableArea.Height - 50));

};
try
{
    p.Print();
}
catch (Exception ex)
{
    throw new Exception("Exception Occured While Printing", ex);
}

I tried to solve it with this article but the method stuck in some loop that I don't know how to fix.

Body:
You have to keep in mind that PrintDocument will raise the event PrintPage as long as you tell it there are more pages. It is your task to keep track of what is printed, what needs to printed next and if you need another page or not.

There are several ways to accomplish that. I have chosen in this case to take the content of your text, check how much of it fits on the current page, DrawString that bit and then update my processing string, called remainingtext to be able to repeat for the next Page. The decision if a next page is needed is controlled by setting HasMorepages of the PrintEvent arguments instance to true or false when we're done.

Here is the code:

PrintDocument p = new PrintDocument();

var font = new Font("Times New Roman", 12);
var margins = p.DefaultPageSettings.Margins;
var layoutArea = new RectangleF(
    margins.Left,
    margins.Top,
    p.DefaultPageSettings.PrintableArea.Width - (margins.Left + margins.Right ),
    p.DefaultPageSettings.PrintableArea.Height - (margins.Top + margins.Bottom));
var layoutSize = layoutArea.Size;
layoutSize.Height = layoutSize.Height - font.GetHeight(); // keep lastline visible
var brush = new SolidBrush(Color.Black);

// what still needs to be printed
var remainingText = text;

p.PrintPage += delegate (object sender1, PrintPageEventArgs e1)
{
    int charsFitted, linesFilled;

    // measure how many characters will fit of the remaining text
    var realsize = e1.Graphics.MeasureString(
        remainingText,
        font,
        layoutSize,
        StringFormat.GenericDefault,
        out charsFitted,  // this will return what we need
        out linesFilled);

    // take from the remainingText what we're going to print on this page
    var fitsOnPage = remainingText.Substring(0, charsFitted);
    // keep what is not printed on this page
    remainingText = remainingText.Substring(charsFitted).Trim();

    // print what fits on the page
    e1.Graphics.DrawString(
        fitsOnPage,
        font,
        brush,
        layoutArea);

    // if there is still text left, tell the PrintDocument it needs to call
    // PrintPage again.
    e1.HasMorePages = remainingText.Length > 0;
};
p.Print();

When I hookup an PrintPreviewControl this is the result:


问:
Odoo - scaffolding?
I read here that you can scaffold a module using a command, so you won't need to manually create some initial files. But such command does not work on master (on Odoo development branch):

```<code>./oe scaffold Academy ../my-modules
</code>```

Because there is no such file called oe in openerp directory. Did this thing change in the newest version? How can I scaffold a module in Odoo?

答:
You can use
./odoo-bin scaffold MODULE_NAME PATH_TO_STORE_YOUR_MODULE_OR_ADDONS

For example:
./odoo-bin scaffold module_name /odoo/odoo-server/custom_addons/

Here custom_addons is your directory in odoo-server/

cmd in Odoo10:

```<code>./odoo-bin scaffold <module_name> <destination path where you want to create>
</code>```

Title: Odoo - scaffolding?

Body:
I read here that you can scaffold a module using a command, so you won't need to manually create some initial files. But such command does not work on master (on Odoo development branch):

./oe scaffold Academy ../my-modules

Because there is no such file called oe in openerp directory. Did this thing change in the newest version? How can I scaffold a module in Odoo?

Body:
You can use
./odoo-bin scaffold MODULE_NAME PATH_TO_STORE_YOUR_MODULE_OR_ADDONS

For example:
./odoo-bin scaffold module_name /odoo/odoo-server/custom_addons/

Here custom_addons is your directory in odoo-server/

cmd in Odoo10:

./odoo-bin scaffold <module_name> <destination path where you want to create>


问:
File upload field not working inside a web view in android
I have a webapplication made in Laravel Framework. I am launching it inside the web view of an android application. All works well but when i press the choose file It does no work. Its completely inactive. How to make it work?

答:
I think you make use of the input attribute in your html, don't you?
As written here (FAQ part) it does not work out-of-the-box in webviews by now.
Maybe you can give the WebChromeClient.onShowFileChooser a shot (added API 21).</p>


问:
CloseButton how can have such a performance
I'm developing MacOS apps, and every time I click on my application's close button, the window closes, but there's the application icon in DOCK. I've found that many applications that close the window will reopen if they click the icon in the Dock, or activate a window. Could you tell me how to achieve this?

Thank you very much for everything you've done for us, thank you.

答:
The corresponding method has been found, in fact, no more complex. I chose a simpler method.
First of all, I need to define a global variable so that I can find it again
So, I define

```<code>Var mainWindowController: NSWindowController?
</code>```

And I've assigned it in the applicationDidFinishLaunching method.
Then there is the implementation of the applicationShouldHandleReopen method, which is only a piece of code that can be implemented

```<code>func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool
{
    if !flag {
        for window in sender.windows {
            window.makeKeyAndOrderFront(self);
        }
    }
    return true
}
</code>```

Thank you very much for the help of the two friends in the front, thank you

Body:
The corresponding method has been found, in fact, no more complex. I chose a simpler method.
First of all, I need to define a global variable so that I can find it again
So, I define

Var mainWindowController: NSWindowController?

And I've assigned it in the applicationDidFinishLaunching method.
Then there is the implementation of the applicationShouldHandleReopen method, which is only a piece of code that can be implemented

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool
{
    if !flag {
        for window in sender.windows {
            window.makeKeyAndOrderFront(self);
        }
    }
    return true
}

Thank you very much for the help of the two friends in the front, thank you


问:
Passing Arrays back to main body
I am pondering upon available functions in the net for my optimization project.. I have stumbled upon an available code by Bateesh and i found it very useful. But I want to slightly modify his code such that

**instead from printing the output, it will be transferred in my main body to be used in the next process.

How do i do it? I have new in C++ so any suggestions will help. I am currently reading about passing arrays but i am dazed by the new ideas.

Thank you.

```<code>    // Program to print all combination of size r in an array of size n
#include <stdio.h>
#include <stdlib.h>
void combinationUtil(int arr[], int n, int r, int count, int data[], int i);

// Needed for qsort.  See http://w...content-available-to-author-only...s.com/reference/cstdlib/qsort/
int compare (const void * a, const void * b)
{
    return ( *(int*)a - *(int*)b );
}

// The main function that prints all combinations of size r
// in arr[] of size n. This function mainly uses combinationUtil()
void printCombination(int arr[], int n, int r)
{
    // A temporary array to store all combination one by one
    int data[r];

    // Sort array to handle duplicates
    qsort (arr, n, sizeof(int), compare);

    // Print all combination using temprary array 'data[]'
    combinationUtil(arr, n, r, 0, data, 0);
}

/* arr[]  ---> Input Array
   n      ---> Size of input array
   r      ---> Size of a combination to be printed
   index  ---> Current index in data[]
   data[] ---> Temporary array to store current combination
   i      ---> index of current element in arr[]     */
void combinationUtil(int arr[], int n, int r, int index, int data[], int i)
{
    // Current cobination is ready, print it
    if (index == r)
    {
        for (int j=0; j<r; j++)
            printf("%d ",data[j]);
        printf("\n");
        return;
    }

    // When no more elements are there to be put
    if (i >= n)
        return;

    // current is included, put next at next location
    data[index] = arr[i];
    combinationUtil(arr, n, r, index+1, data, i+1);

    // Remove duplicates
    while (arr[i] == arr[i+1])
        i++;

    // current is excluded, replace it with next (Note that
    // i+1 is passed, but index is not changed)
    combinationUtil(arr, n, r, index, data, i+1);
}

// Driver program to test above functions
int main()
{
    int arr[] = {1, 2, 1, 3, 1};
    int r = 3;
    int n = sizeof(arr)/sizeof(arr[0]);
    printCombination(arr, n, r);
    return 0;
}
</code>```

答:
Do not use arrays at all

I am not going to answer the question you asked, as I consider raw arrays bad in most situations. Even more so if they are passed around (and that is what you are asking for).

C++ does, however, provide alternatives to raw arrays (std::array and std::vector comes to mind). I would recommend to prefere these over raw arrays unless you are writing a container yourself. They are quite solid performance wise.

Do use C++ standard library functions

If I understand you correctly, you are trying to display all possible permutations of the unique values in a given collection of numbers. You could do this using some C++ library functions:

```<code>#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
  // Create vector
  std::vector<int> v { 1, 2, 1, 3, 1 };

  // Sort vector
  std::sort(v.begin(), v.end());

  // Move all duplicate entries to the end of the vector
  auto it = std::unique(v.begin(), v.end());

  // Trim vector so that the duplicates are no longer contained
  v.resize(std::distance(v.begin(), it));

  // Iterate as long as the function can rearrange the objects as a
  // lexicographicaly greater permutation
  do
  {
    // Print all elements in the vector
    for(auto i : v)
      std::cout << i << " ";

    // Add new line character and flush output
    std::cout << std::endl;

  } while(std::next_permutation(v.begin(),v.end()));

  return 0;
}
</code>```

Output:

```<code>1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
</code>```

Title: Passing Arrays back to main body

Body:
I am pondering upon available functions in the net for my optimization project.. I have stumbled upon an available code by Bateesh and i found it very useful. But I want to slightly modify his code such that

**instead from printing the output, it will be transferred in my main body to be used in the next process.

How do i do it? I have new in C++ so any suggestions will help. I am currently reading about passing arrays but i am dazed by the new ideas.

Thank you.

    // Program to print all combination of size r in an array of size n
#include <stdio.h>
#include <stdlib.h>
void combinationUtil(int arr[], int n, int r, int count, int data[], int i);

// Needed for qsort.  See http://w...content-available-to-author-only...s.com/reference/cstdlib/qsort/
int compare (const void * a, const void * b)
{
    return ( *(int*)a - *(int*)b );
}

// The main function that prints all combinations of size r
// in arr[] of size n. This function mainly uses combinationUtil()
void printCombination(int arr[], int n, int r)
{
    // A temporary array to store all combination one by one
    int data[r];

    // Sort array to handle duplicates
    qsort (arr, n, sizeof(int), compare);

    // Print all combination using temprary array 'data[]'
    combinationUtil(arr, n, r, 0, data, 0);
}

/* arr[]  ---> Input Array
   n      ---> Size of input array
   r      ---> Size of a combination to be printed
   index  ---> Current index in data[]
   data[] ---> Temporary array to store current combination
   i      ---> index of current element in arr[]     */
void combinationUtil(int arr[], int n, int r, int index, int data[], int i)
{
    // Current cobination is ready, print it
    if (index == r)
    {
        for (int j=0; j<r; j++)
            printf("%d ",data[j]);
        printf("\n");
        return;
    }

    // When no more elements are there to be put
    if (i >= n)
        return;

    // current is included, put next at next location
    data[index] = arr[i];
    combinationUtil(arr, n, r, index+1, data, i+1);

    // Remove duplicates
    while (arr[i] == arr[i+1])
        i++;

    // current is excluded, replace it with next (Note that
    // i+1 is passed, but index is not changed)
    combinationUtil(arr, n, r, index, data, i+1);
}

// Driver program to test above functions
int main()
{
    int arr[] = {1, 2, 1, 3, 1};
    int r = 3;
    int n = sizeof(arr)/sizeof(arr[0]);
    printCombination(arr, n, r);
    return 0;
}

Body:
Do not use arrays at all

I am not going to answer the question you asked, as I consider raw arrays bad in most situations. Even more so if they are passed around (and that is what you are asking for).

C++ does, however, provide alternatives to raw arrays (std::array and std::vector comes to mind). I would recommend to prefere these over raw arrays unless you are writing a container yourself. They are quite solid performance wise.

Do use C++ standard library functions

If I understand you correctly, you are trying to display all possible permutations of the unique values in a given collection of numbers. You could do this using some C++ library functions:

#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
  // Create vector
  std::vector<int> v { 1, 2, 1, 3, 1 };

  // Sort vector
  std::sort(v.begin(), v.end());

  // Move all duplicate entries to the end of the vector
  auto it = std::unique(v.begin(), v.end());

  // Trim vector so that the duplicates are no longer contained
  v.resize(std::distance(v.begin(), it));

  // Iterate as long as the function can rearrange the objects as a
  // lexicographicaly greater permutation
  do
  {
    // Print all elements in the vector
    for(auto i : v)
      std::cout << i << " ";

    // Add new line character and flush output
    std::cout << std::endl;

  } while(std::next_permutation(v.begin(),v.end()));

  return 0;
}

Output:

1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1


问:
How to restrict user to use specific domain to sign up my app using firebase
I'm currently developing an app for my university using Ionic 2 and Firebase. So, the problem is how to restrict user from signing up unless they're using specific domain eg.(@ukm.edu.my)? It's for my university, I don't want anyone else to use this app. So, anyone without that specific email domain can't sign up for my app.

From what I've read, Firebase database rules only affect authorization. So, how to setup rules for authentication?

答:
You can't do it with what Firebase provides.

You can only restrict access to the database adding a rule stating that users with email in a specific domain can access it.

```<code>{
  "rules": {
    ".read": "auth.token.email.endsWith('@example.com')",
    ".write": "auth.token.email.endsWith('@example.com')",
  }
}
</code>```

Body:
You can't do it with what Firebase provides.

You can only restrict access to the database adding a rule stating that users with email in a specific domain can access it.

{
  "rules": {
    ".read": "auth.token.email.endsWith('@example.com')",
    ".write": "auth.token.email.endsWith('@example.com')",
  }
}


问:
error in zend session database for php7
My application need to use database instead of file for the session management.
My Application is based on Zend Framework 1.12.17, php 5.6.25 and actualy on wampserver

That is my config.ini

```<code>resources.session.use_only_cookies = true
resources.session.gc_maxlifetime = 864000
resources.session.remember_me_seconds = 864000
resources.session.gc_probability = 1
resources.session.gc_divisor = 100
resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "app_session"
resources.session.saveHandler.options.primary = "id"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"
</code>```

When I want to upgrade php to php 7.0.10, a warning occurred

Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (D:\wamp\www\myapp\top\session) in D:\wamp\www\myapp\top\library\versions\ZendFramework-1.12.17-minimal\library\Zend\Session.php on line 732

I'm looking for the origin of this problem. Do you have an idea?

Thanks a lot

答:
In addition to edigus answer here is such a simple implementation of the extended save handler:</p>

```<code><?php

require_once 'Zend/Session/SaveHandler/DbTable.php';

// NOTE: To fix an issue with Zend_Session_SaveHandler_DbTable on PHP 7 this class extends it and overrides the write
// method to simply always return true.
//
// See: https://stackoverflow.com/a/44985594/1510754
// See: https://github.com/zendframework/zf1/issues/665
// See: https://github.com/zendframework/zf1/pull/654

class My_Session_SaveHandler_DbTable extends Zend_Session_SaveHandler_DbTable
{

    public function write($id, $data)
    {
        parent::write($id, $data);
        return true;
    }

}
</code>```

Title: error in zend session database for php7

Body:
My application need to use database instead of file for the session management.
My Application is based on Zend Framework 1.12.17, php 5.6.25 and actualy on wampserver

That is my config.ini

resources.session.use_only_cookies = true
resources.session.gc_maxlifetime = 864000
resources.session.remember_me_seconds = 864000
resources.session.gc_probability = 1
resources.session.gc_divisor = 100
resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "app_session"
resources.session.saveHandler.options.primary = "id"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"

When I want to upgrade php to php 7.0.10, a warning occurred

Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (D:\wamp\www\myapp\top\session) in D:\wamp\www\myapp\top\library\versions\ZendFramework-1.12.17-minimal\library\Zend\Session.php on line 732

I'm looking for the origin of this problem. Do you have an idea?

Thanks a lot

Body:
In addition to edigus answer here is such a simple implementation of the extended save handler:

<?php

require_once 'Zend/Session/SaveHandler/DbTable.php';

// NOTE: To fix an issue with Zend_Session_SaveHandler_DbTable on PHP 7 this class extends it and overrides the write
// method to simply always return true.
//
// See: https://stackoverflow.com/a/44985594/1510754
// See: https://github.com/zendframework/zf1/issues/665
// See: https://github.com/zendframework/zf1/pull/654

class My_Session_SaveHandler_DbTable extends Zend_Session_SaveHandler_DbTable
{

    public function write($id, $data)
    {
        parent::write($id, $data);
        return true;
    }

}


问:
Dynamic Angular Js Not working via innerHTML
If I add a row with Dynamic Angular JS variable, it is not working.
Below is my code. Please help me let know the issue.

Also please note that the inner HTML in my original code is 600 lines long. In this example I have used simple div to simplify.

```<code><div data-ng-init="quantity_r=1;price_r=5">
   <h2>Cost Calculator Quantity:</h2>
   <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">
 <div>
Total in dollar: {{quantity_r * price_r}}
 </div>
</code>```

<!DOCTYPE html>

<button onclick="replicateRegion()">insert Row</button>

Cost Calculator Quantity:

   <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">

Total in dollar: {{quantity_r * price_r}}

```

Only the first row which is static has the correct output. The rows added after button-click "Insert Row" have the problematic Angular JS output. Please help.

答:
You need to add the code for replicateRegion() function inside the AngularJS controller and use the $compile service to bind the dynamically generated HTML into the AngularJS DOM.

var myapp = angular.module('myApp', []);

myapp.controller('AppCtrl', function ($compile, $scope) {

    $scope.a = 1;
    $scope.b = 2;
    $scope.replicateRegion = function(){
      var table = document.getElementById("idTable");
      var lastRow = table.rows.length;

      var row = table.insertRow(lastRow);

      var template = `

Cost Calculator Quantity:

               <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">

            Total in dollar: {{quantity_r * price_r}}

`;

           var cell1 = row.insertCell(0);

         template=template.replace(/_r/g, "_r" + lastRow.toString());
         template=template.replace("Cost Calculator Quantity:", "Cost Calculator Quantity: Row Added " + lastRow.toString());
            cell1.innerHTML = template;
          $compile(cell1)($scope); //Now compile it to render the directive.
    }

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

 <div id="id1" ng-app="myApp" ng-controller="AppCtrl">
<button ng-click="replicateRegion()">insert Row</button>
<table id="idTable">
<tr><td id="idTableTD1">

 <div data-ng-init="quantity_r=1;price_r=5">
   <h2>Cost Calculator Quantity:</h2>
   <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">
 <div>
Total in dollar: {{quantity_r * price_r}}
 </div>
 </div>

</td></tr>

</table>

</div> </code>```

Also notice that var template that specifies a generic template that should be inserted in the HTML dynamically on click. It is always a good practice to specify a static HTML template instead of extracting the generated HTML from the page and using that, which you have done.

Body:
If I add a row with Dynamic Angular JS variable, it is not working.
Below is my code. Please help me let know the issue.

Also please note that the inner HTML in my original code is 600 lines long. In this example I have used simple div to simplify.

Cost Calculator Quantity:

   <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">

Total in dollar: {{quantity_r * price_r}}

<!DOCTYPE html>

<button onclick="replicateRegion()">insert Row</button>

Cost Calculator Quantity:

   <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">

Total in dollar: {{quantity_r * price_r}}

Only the first row which is static has the correct output. The rows added after button-click "Insert Row" have the problematic Angular JS output. Please help.

Body:
You need to add the code for replicateRegion() function inside the AngularJS controller and use the $compile service to bind the dynamically generated HTML into the AngularJS DOM.

var myapp = angular.module('myApp', []);

myapp.controller('AppCtrl', function ($compile, $scope) {

    $scope.a = 1;
    $scope.b = 2;
    $scope.replicateRegion = function(){
      var table = document.getElementById("idTable");
      var lastRow = table.rows.length;

      var row = table.insertRow(lastRow);

      var template = `<div data-ng-init="quantity_r=1;price_r=5">
               <h2>Cost Calculator Quantity:</h2>
               <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">
             <div>
            Total in dollar: {{quantity_r * price_r}}
             </div>
             </div>`;

           var cell1 = row.insertCell(0);

         template=template.replace(/_r/g, "_r" + lastRow.toString());
         template=template.replace("Cost Calculator Quantity:", "Cost Calculator Quantity: Row Added " + lastRow.toString());
            cell1.innerHTML = template;
          $compile(cell1)($scope); //Now compile it to render the directive.
    }

});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

 <div id="id1" ng-app="myApp" ng-controller="AppCtrl">
<button ng-click="replicateRegion()">insert Row</button>
<table id="idTable">
<tr><td id="idTableTD1">

 <div data-ng-init="quantity_r=1;price_r=5">
   <h2>Cost Calculator Quantity:</h2>
   <input type="number" ng-model="quantity_r"> Price: <input type="number" ng-model="price_r">
 <div>
Total in dollar: {{quantity_r * price_r}}
 </div>
 </div>

</td></tr>

</table>

</div>

Also notice that var template that specifies a generic template that should be inserted in the HTML dynamically on click. It is always a good practice to specify a static HTML template instead of extracting the generated HTML from the page and using that, which you have done.


问:
Is there a way to figure out what is using a Linux kernel module?
If I load a kernel module and list the loaded modules with lsmod, I can get the "use count" of the module (number of other modules with a reference to the module). Is there a way to figure out what is using a module, though?

The issue is that a module I am developing insists its use count is 1 and thus I cannot use rmmod to unload it, but its "by" column is empty. This means that every time I want to re-compile and re-load the module, I have to reboot the machine (or, at least, I can't figure out any other way to unload it).

答:
It says on the Linux Kernel Module Programming Guide that the use count of a module is controlled by the functions try_module_get and module_put. Perhaps you can find where these functions are called for your module.

More info: https://www.kernel.org/doc/htmldocs/kernel-hacking/routines-module-use-counters.html

OwnerDisplayName: mipadi

LastEditorDisplayName: mipadi


问:
Accessing controls in the edititemtemplate of a listview
I am working with the listview control. By default I am showing the itemtemplate with an edit button. When the edit button is pressed the listview switches to the edititemtemplate. I need to populate one of the controls in the edititemtemplate based on the item being edited - I've tried accessing the control (via FindControl) in the ItemEditing event (and pretty much every other event as well), however the controls just don't seem to exist. I can access controls in the itemtemplate ok, but not the edititemtemplate.

Can anyone let me know how I can access a control held within the edititemtemplate of a listview, and from which event I should do so?

EDIT
I'm trying to access the control using this:

```<code>protected void UnitsLV_ItemEditing(object sender, ListViewEditEventArgs e)
{
    ListViewItem item = UnitsLV.Items[e.NewEditIndex];
    ListBox tempLB = (ListBox)e.item.FindControl("ListBox3");
}
</code>```

I've also tried in ItemDataBound and ItemCreated.

The listview declaration is:

```<code><asp:Content ID="Content1" ContentPlaceHolderID="ColumnA" runat="server">
    <asp:Panel ID="Panel1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Panel ID="SummaryPnl" runat="server">
                    <asp:ListView ID="UnitsLV" runat="server" DataSourceID="DataLDS" DataKeyNames="u_uid"
                        InsertItemPosition="LastItem" OnItemInserting="UnitsLV_ItemInserting" OnItemDataBound="UnitsLV_ItemDataBound"
                        OnItemCreated="UnitsLV_ItemCreated" onitemediting="UnitsLV_ItemEditing">
                        <ItemTemplate>
                            <tr class="rowA">
                                <td>
                                    <asp:Label runat="server" ID="UnitIDLbl" Text='<%# Eval("u_uid")%>'></asp:Label>
                                </td>
                                <td>
                                    <%# Eval("u_Title")%>
                                </td>
                                <td>
                                    <asp:LinkButton ID="EditBtn" runat="server" CommandName="Edit" CommandArgument='<%#Eval("u_uid") %>'
                                    Text="Edit" />
                                </td>
                                <td>
                                    <asp:LinkButton ID="DeleteBtn" runat="server" CommandName="Delete" CommandArgument='<%#Eval("u_uid") %>'
                                    Text="Delete" />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <tr class="rowB">
                                <td>
                                    <br />

                                </td>
                                <td>
                                    <br />
                                    <asp:TextBox ID="TitleTB" runat="server" Text='<% #Bind("u_Title")%>'></asp:TextBox>
                                </td>
                                <td>
                                    <br />
                                    <asp:ListBox ID="ListBox3" runat="server"></asp:ListBox>
                                    <asp:ListBox ID="ToBeDeletedLB" runat="server"></asp:ListBox>
                                </td>
                                <td>
                                    <asp:LinkButton ID="InsertBtn" runat="server" CommandName="Insert" Text="Insert" />
                                </td>
                                <td>
                                    <asp:LinkButton ID="CancelBtn" runat="server" CommandName="Cancel" Text="Cancel" />
                                </td>
                            </tr>
                        </InsertItemTemplate>
                        <EditItemTemplate>
                            <tr class="rowB">
                                <td>
                                    <br />
                                    <asp:Label runat="server" ID="UnitIDLbl" Text='<%# Bind("u_uid")%>'></asp:Label>
                                </td>
                                <td>
                                    <br />
                                    <asp:TextBox ID="TitleTB" runat="server" Text='<% #Bind("u_Title")%>'></asp:TextBox>
                                </td>
                                <td>
                                    <br />
                                    <asp:ListBox ID="ListBox3" runat="server"></asp:ListBox>
                                    <asp:ListBox ID="ToBeDeletedLB" runat="server"></asp:ListBox>
                                </td>
                                <td>
                                    <asp:LinkButton ID="UpdateBtn" runat="server" CommandName="Update" Text="Update" />
                                </td>
                                <td>
                                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" Text="Cancel" />
                                </td>
                            </tr>
                        </EditItemTemplate>
                        <LayoutTemplate>
                            <table id="Table2" runat="server" width="100%">
                                <tr id="Tr1" runat="server">
                                    <td id="Td1" runat="server">
                                        <table id="itemPlaceholderContainer" runat="server" border="0" style="" width="100%">
                                            <tr id="itemPlaceholder" runat="server"></tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr id="Tr2" runat="server">
                                    <td id="Td2" runat="server" style=""></td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                    </asp:ListView>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
</asp:Content>
</code>```

EDIT:
I've iterated over all the controls in the listview using code similar to below, and the control is still not visible. Does the ItemEditing event fire before the edit template is shown? If so, what event can I use to access the edit template controls?

```<code>foreach (Control child in control.Controls)
{
   Control result = Find(child, id);
   if (result != null)
   {
      return result;
   }
}
</code>```

**EDIT: **
I can access the controls in the edititemtemplate in the listview's ItemCreated event, however none they have no content (I'd assume the data hasn't been bound yet), so I can't get the key-value I need to do a lookup to get the data I need to populate the control.

答:
I don't know about previous editions but in Visual Studio 2010 you can easily access the edit item trhough the "ListView.EditItem" property like this:</p>

```<code>private void myListView_ItemEditing(object sender, ListViewEditEventArgs e)
{
   myListView.EditIndex = e.NewEditIndex;
   myListView.DataBind();

   ListViewItem lvwItem = lvwLista.EditItem;
   ListBox tempLB = (ListBox) lvwItem.FindControl("ListBox3");
}
</code>```

OwnerDisplayName: marc

LastEditorDisplayName: marc

Body:
I am working with the listview control. By default I am showing the itemtemplate with an edit button. When the edit button is pressed the listview switches to the edititemtemplate. I need to populate one of the controls in the edititemtemplate based on the item being edited - I've tried accessing the control (via FindControl) in the ItemEditing event (and pretty much every other event as well), however the controls just don't seem to exist. I can access controls in the itemtemplate ok, but not the edititemtemplate.

Can anyone let me know how I can access a control held within the edititemtemplate of a listview, and from which event I should do so?

EDIT
I'm trying to access the control using this:

protected void UnitsLV_ItemEditing(object sender, ListViewEditEventArgs e)
{
    ListViewItem item = UnitsLV.Items[e.NewEditIndex];
    ListBox tempLB = (ListBox)e.item.FindControl("ListBox3");
}

I've also tried in ItemDataBound and ItemCreated.

The listview declaration is:

<asp:Content ID="Content1" ContentPlaceHolderID="ColumnA" runat="server">
    <asp:Panel ID="Panel1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Panel ID="SummaryPnl" runat="server">
                    <asp:ListView ID="UnitsLV" runat="server" DataSourceID="DataLDS" DataKeyNames="u_uid"
                        InsertItemPosition="LastItem" OnItemInserting="UnitsLV_ItemInserting" OnItemDataBound="UnitsLV_ItemDataBound"
                        OnItemCreated="UnitsLV_ItemCreated" onitemediting="UnitsLV_ItemEditing">
                        <ItemTemplate>

                                    <asp:Label runat="server" ID="UnitIDLbl" Text='<%# Eval("u_uid")%>'></asp:Label>

                                    <%# Eval("u_Title")%>

                                    <asp:LinkButton ID="EditBtn" runat="server" CommandName="Edit" CommandArgument='<%#Eval("u_uid") %>'
                                    Text="Edit" />

                                    <asp:LinkButton ID="DeleteBtn" runat="server" CommandName="Delete" CommandArgument='<%#Eval("u_uid") %>'
                                    Text="Delete" />

                        </ItemTemplate>
                        <InsertItemTemplate>

                                    <asp:TextBox ID="TitleTB" runat="server" Text='<% #Bind("u_Title")%>'></asp:TextBox>

                                    <asp:ListBox ID="ListBox3" runat="server"></asp:ListBox>
                                    <asp:ListBox ID="ToBeDeletedLB" runat="server"></asp:ListBox>

                                    <asp:LinkButton ID="InsertBtn" runat="server" CommandName="Insert" Text="Insert" />

                                    <asp:LinkButton ID="CancelBtn" runat="server" CommandName="Cancel" Text="Cancel" />

                        </InsertItemTemplate>
                        <EditItemTemplate>

                                    <asp:Label runat="server" ID="UnitIDLbl" Text='<%# Bind("u_uid")%>'></asp:Label>

                                    <asp:TextBox ID="TitleTB" runat="server" Text='<% #Bind("u_Title")%>'></asp:TextBox>

                                    <asp:ListBox ID="ListBox3" runat="server"></asp:ListBox>
                                    <asp:ListBox ID="ToBeDeletedLB" runat="server"></asp:ListBox>

                                    <asp:LinkButton ID="UpdateBtn" runat="server" CommandName="Update" Text="Update" />

                                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" Text="Cancel" />

                        </EditItemTemplate>
                        <LayoutTemplate>

                        </LayoutTemplate>
                    </asp:ListView>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
</asp:Content>

EDIT:
I've iterated over all the controls in the listview using code similar to below, and the control is still not visible. Does the ItemEditing event fire before the edit template is shown? If so, what event can I use to access the edit template controls?

foreach (Control child in control.Controls)
{
   Control result = Find(child, id);
   if (result != null)
   {
      return result;
   }
}

**EDIT: **
I can access the controls in the edititemtemplate in the listview's ItemCreated event, however none they have no content (I'd assume the data hasn't been bound yet), so I can't get the key-value I need to do a lookup to get the data I need to populate the control.

Body:
I don't know about previous editions but in Visual Studio 2010 you can easily access the edit item trhough the "ListView.EditItem" property like this:

private void myListView_ItemEditing(object sender, ListViewEditEventArgs e)
{
   myListView.EditIndex = e.NewEditIndex;
   myListView.DataBind();

   ListViewItem lvwItem = lvwLista.EditItem;
   ListBox tempLB = (ListBox) lvwItem.FindControl("ListBox3");
}


问:
How to handle bottom navigation perfectly with back pressed
I am working on a bottom navigation bar, but I am not getting perfectly bottom navigation bar.

My MainActivity class:

```<code>public class MainActivity extends AppCompatActivity {

    private static final String SELECTED_ITEM = "selected_item";

    private BottomNavigationView bottomNavigationView;
    private Toolbar toolbar;
    private MenuItem menuItemSelected;
    private int mMenuItemSelected;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                selectFragment(item);
                return true;
            }
        });

        //Always load first fragment as default
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.frameLayout, new AnnouncementFragment());
        fragmentTransaction.commit();

        if (savedInstanceState != null) {
            mMenuItemSelected = savedInstanceState.getInt(SELECTED_ITEM, 0);
            menuItemSelected = bottomNavigationView.getMenu().findItem(mMenuItemSelected);
        } else {
            menuItemSelected = bottomNavigationView.getMenu().getItem(0);
        }

        selectFragment(menuItemSelected);
    }

    private void selectFragment(MenuItem item) {
        Fragment fragment = null;
        Class fragmentClass;
        switch (item.getItemId()) {
            case R.id.action_announcement:
                fragmentClass = AnnouncementFragment.class;
                break;
            case R.id.action_menu:
                fragmentClass = MenuFragment.class;
                break;
            case R.id.action_menu_reports:
                fragmentClass = ReportFragment.class;
                break;
            case R.id.action_setting:
                fragmentClass = SettingFragment.class;
                break;

            default:
                fragmentClass = AnnouncementFragment.class;
        }

        try {
            fragment = (Fragment) fragmentClass.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.frameLayout, fragment).commit();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putInt(SELECTED_ITEM, mMenuItemSelected);
        super.onSaveInstanceState(outState);
    }
</code>```

And my back pressed also not working properly:

```<code> @Override
    public void onBackPressed() {
        MenuItem homeItem = bottomNavigationView.getMenu().getItem(0);
        if (mMenuItemSelected != homeItem.getItemId()) {
            selectFragment(homeItem);
        } else {
            super.onBackPressed();
        }
    }
</code>```

How should I do that because bottom menu has uneven distribution on bar. How to properly maintain the menu space without uneven distribution.

Here I am attaching my result which I obtain on AVD

答:
I was facing the same problem but after doing this I got the solution

First Paste this code in your main activity (where you are using Bottom navigation bar)

```<code>BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.navigation);
BottomNavigationViewHelper.disableShiftMode(bottomNavigationView);
</code>```

And then create a class named BottomNavigationViewHelper and paste the following code.

```<code>public class BottomNavigationViewHelper {
public static void disableShiftMode(BottomNavigationView view) {
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
    try {
        Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
        shiftingMode.setAccessible(true);
        shiftingMode.setBoolean(menuView, false);
        shiftingMode.setAccessible(false);
        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
            //noinspection RestrictedApi
            item.setShiftingMode(false);
            // set once again checked value, so view will be updated
            //noinspection RestrictedApi
            item.setChecked(item.getItemData().isChecked());
        }
    } catch (NoSuchFieldException e) {
        Log.e("BNVHelper", "Unable to get shift mode field", e);
    } catch (IllegalAccessException e) {
        Log.e("BNVHelper", "Unable to change value of shift mode", e);
    }
}
</code>```

}

Hope It helps

Body:
I am working on a bottom navigation bar, but I am not getting perfectly bottom navigation bar.

My MainActivity class:

public class MainActivity extends AppCompatActivity {

    private static final String SELECTED_ITEM = "selected_item";

    private BottomNavigationView bottomNavigationView;
    private Toolbar toolbar;
    private MenuItem menuItemSelected;
    private int mMenuItemSelected;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                selectFragment(item);
                return true;
            }
        });

        //Always load first fragment as default
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.frameLayout, new AnnouncementFragment());
        fragmentTransaction.commit();

        if (savedInstanceState != null) {
            mMenuItemSelected = savedInstanceState.getInt(SELECTED_ITEM, 0);
            menuItemSelected = bottomNavigationView.getMenu().findItem(mMenuItemSelected);
        } else {
            menuItemSelected = bottomNavigationView.getMenu().getItem(0);
        }

        selectFragment(menuItemSelected);
    }

    private void selectFragment(MenuItem item) {
        Fragment fragment = null;
        Class fragmentClass;
        switch (item.getItemId()) {
            case R.id.action_announcement:
                fragmentClass = AnnouncementFragment.class;
                break;
            case R.id.action_menu:
                fragmentClass = MenuFragment.class;
                break;
            case R.id.action_menu_reports:
                fragmentClass = ReportFragment.class;
                break;
            case R.id.action_setting:
                fragmentClass = SettingFragment.class;
                break;

            default:
                fragmentClass = AnnouncementFragment.class;
        }

        try {
            fragment = (Fragment) fragmentClass.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.frameLayout, fragment).commit();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putInt(SELECTED_ITEM, mMenuItemSelected);
        super.onSaveInstanceState(outState);
    }

And my back pressed also not working properly:

 @Override
    public void onBackPressed() {
        MenuItem homeItem = bottomNavigationView.getMenu().getItem(0);
        if (mMenuItemSelected != homeItem.getItemId()) {
            selectFragment(homeItem);
        } else {
            super.onBackPressed();
        }
    }

How should I do that because bottom menu has uneven distribution on bar. How to properly maintain the menu space without uneven distribution.

Here I am attaching my result which I obtain on AVD

Body:
I was facing the same problem but after doing this I got the solution

First Paste this code in your main activity (where you are using Bottom navigation bar)

BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.navigation);
BottomNavigationViewHelper.disableShiftMode(bottomNavigationView);

And then create a class named BottomNavigationViewHelper and paste the following code.

public class BottomNavigationViewHelper {
public static void disableShiftMode(BottomNavigationView view) {
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
    try {
        Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
        shiftingMode.setAccessible(true);
        shiftingMode.setBoolean(menuView, false);
        shiftingMode.setAccessible(false);
        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
            //noinspection RestrictedApi
            item.setShiftingMode(false);
            // set once again checked value, so view will be updated
            //noinspection RestrictedApi
            item.setChecked(item.getItemData().isChecked());
        }
    } catch (NoSuchFieldException e) {
        Log.e("BNVHelper", "Unable to get shift mode field", e);
    } catch (IllegalAccessException e) {
        Log.e("BNVHelper", "Unable to change value of shift mode", e);
    }
}

}

Hope It helps


问:
Getting error while using parameterised like query in Python
I am getting the following error while trying to use like query for sqlite3 db using python.

Error:

```<code>Request Method: POST
Request URL:    http://127.0.0.1:8000/search/
Django Version: 1.11.2
Exception Type: ProgrammingError
Exception Value:Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied.
</code>```

I am explaining my query below.

```<code>rname = request.POST.get('rname')
keyword = '%' + rname + '%'
cursor.execute("SELECT * FROM booking_meeting WHERE room_name LIKE ? ",(keyword))
</code>```

Here I need to fetch value from table as per keyword. Please help me to resolve this error.

答:
cursor.execute("SELECT * FROM booking_meeting WHERE room_name LIKE ? ",(keyword))

execute's second argument must be a tuple even if there is only one parameter:

```<code>cursor.execute("SELECT * FROM booking_meeting WHERE room_name LIKE ? ",(keyword,))
                                                                             # ^
</code>```

Body:
I am getting the following error while trying to use like query for sqlite3 db using python.

Error:

Request Method: POST
Request URL:    http://127.0.0.1:8000/search/
Django Version: 1.11.2
Exception Type: ProgrammingError
Exception Value:Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied.

I am explaining my query below.

rname = request.POST.get('rname')
keyword = '%' + rname + '%'
cursor.execute("SELECT * FROM booking_meeting WHERE room_name LIKE ? ",(keyword))

Here I need to fetch value from table as per keyword. Please help me to resolve this error.

Body:
cursor.execute("SELECT * FROM booking_meeting WHERE room_name LIKE ? ",(keyword))

execute's second argument must be a tuple even if there is only one parameter:

cursor.execute("SELECT * FROM booking_meeting WHERE room_name LIKE ? ",(keyword,))
                                                                             # ^


问:
Is it possible to send an iOS app to a client to test without an Apple Developer ID and iPhone device?
I'm working on an iOS app. Just now I've completed my app. I'm testing it in simulator. Now I want to send this app to a client to test.

I do not have an Apple developer account (paid) and neither does my client. Also I do not have an iPhone device. Is it possible to give my app to client without these? If yes, what is the process?

答:
Strictly not! you need an Apple developer account for the development testing and uploading your app to App store as well.

From here, you can choose the membership. And here is an App Distribution Quick Start.

You have to register your devices in your developer account. That's how it works!. It associates with all the device UDIDs with your developer account.


问:
Run-time error, using undeclared variable, C++
Im having this really weird error during run-time.
My program takes two parameters, does some math calculus with them and std::cout's the values in the end.
My program works if i input somevalues, but if i input other values it says that a variable is being used without being initialized, which i think it makes no sence.

Here is the code:

```<code>#include <iostream>
#include <stdio.h>
#include <cmath>

double align_nb(int n) { return { ceil(n / 512.0)*512.0 }; }    // bytes
double align_pt(int k) { return { floor(k / 512.0)*512.0 }; }   // pointer

int main(int argc, char * argv[])
{
    int o_n = std::atoi(argv[1]);       // original number
    int o_p = std::atoi(argv[2]);       // original pointer

    int max_bytes, new_pointer;         // max bytes to read, new pointer to point

    float log = (std::log(o_n) / std::log(2));
    if (log != floor(log))
    {
        max_bytes = align_nb(o_n);      // bytes alinhados para a frente
        new_pointer = align_pt(o_p);    // ponteiro alinhado atrás
    }

    else if (log == floor(log))
    {
        new_pointer = align_pt(o_p);
        if (max_bytes + (o_p - new_pointer) >max_bytes)
        {
            max_bytes += 512;
        }
    }

    std::cout << "Original bytes= " << o_n << std::endl;
    std::cout << "Original pointer= " << o_p << std::endl;
    std::cout << "Max_bytes= " << max_bytes << std::endl;
    std::cout << "new_pointer= " << new_pointer << std::endl;
    return 0;
}
</code>```

Here are the values i tested it and it crashed, giving me that run-time error:

2048 513

1024 500

here is one example of values were the code doesnt give me that error and the program works:

513 520

Here is a print of the error it gives me.

I'd really appreciate someone explaining me why it gives me that error/how to fix it.
Regardless, thanks!

(PS: math tag is included cause it could be the math in the program that is causing it to crash. If annyone thinks it shoudlnt be used in this question, let me know in the comments and ill remove it.)

(PS 2: the variable it complains when it gives me the run time error is 'max_bytes'.)

答:
Make sure that for each path your code takes the values of the variables you use are initialized. If you don't you get what is called Undefined Behaviour. There could be anything in an uninitialized variable.</p>

```<code>int max_bytes;
....
....
expression_involving_max_byte <- Dangerous!
</code>```

Body:
Im having this really weird error during run-time.
My program takes two parameters, does some math calculus with them and std::cout's the values in the end.
My program works if i input somevalues, but if i input other values it says that a variable is being used without being initialized, which i think it makes no sence.

Here is the code:

#include <iostream>
#include <stdio.h>
#include <cmath>

double align_nb(int n) { return { ceil(n / 512.0)*512.0 }; }    // bytes
double align_pt(int k) { return { floor(k / 512.0)*512.0 }; }   // pointer

int main(int argc, char * argv[])
{
    int o_n = std::atoi(argv[1]);       // original number
    int o_p = std::atoi(argv[2]);       // original pointer

    int max_bytes, new_pointer;         // max bytes to read, new pointer to point

    float log = (std::log(o_n) / std::log(2));
    if (log != floor(log))
    {
        max_bytes = align_nb(o_n);      // bytes alinhados para a frente
        new_pointer = align_pt(o_p);    // ponteiro alinhado atrás
    }

    else if (log == floor(log))
    {
        new_pointer = align_pt(o_p);
        if (max_bytes + (o_p - new_pointer) >max_bytes)
        {
            max_bytes += 512;
        }
    }

    std::cout << "Original bytes= " << o_n << std::endl;
    std::cout << "Original pointer= " << o_p << std::endl;
    std::cout << "Max_bytes= " << max_bytes << std::endl;
    std::cout << "new_pointer= " << new_pointer << std::endl;
    return 0;
}

Here are the values i tested it and it crashed, giving me that run-time error:

2048 513

1024 500

here is one example of values were the code doesnt give me that error and the program works:

513 520

Here is a print of the error it gives me.

I'd really appreciate someone explaining me why it gives me that error/how to fix it.
Regardless, thanks!

(PS: math tag is included cause it could be the math in the program that is causing it to crash. If annyone thinks it shoudlnt be used in this question, let me know in the comments and ill remove it.)

(PS 2: the variable it complains when it gives me the run time error is 'max_bytes'.)

Body:
Make sure that for each path your code takes the values of the variables you use are initialized. If you don't you get what is called Undefined Behaviour. There could be anything in an uninitialized variable.

int max_bytes;
....
....
expression_involving_max_byte <- Dangerous!


问:
How to remove url (shown after links) from a printed page (Chrome)?
Not referring to the URL at top of page.

When an  tag is printed in Chrome, it shows the URL after it.

Instead of just showing the anchor text (like this: StackOverflow)

It shows the anchor text w/ URL after it

(like this: StackOverflow (window.open('www.stackoverflow.com'))

This makes the printed page stretch off the printable area, and I'm trying to avoid this from happening.  Can this setting be disabled somehow in printing mode or is there a @media print style that can be defined to remove this URL part from print screen?

答:
Simply use this,</p>

```<code><style type="text/css" media="print">
@page {
    size: auto;   /* auto is the initial value */
    margin: 0;  /* this affects the margin in the printer settings */
}
</style>
</code>```

Body:
Simply use this,

<style type="text/css" media="print">
@page {
    size: auto;   /* auto is the initial value */
    margin: 0;  /* this affects the margin in the printer settings */
}
</style>


问:
Unable to respond with basic_card on Actions on Google
I'm building an app using Api.ai with where I need to respond to an Intent named Login by a basic card. I'm trying this without webhook fulfillment.
By Api.ai try section my query returns this:

{
  "id": "bb09aa94-a2d0-48d5-8c7f-62fc688d17b1",
  "timestamp": "2017-07-06T13:19:30.776Z",
  "lang": "en",
  "result": {
"source": "agent",
"resolvedQuery": "login",
"action": "Login",
"actionIncomplete": false,
"parameters": {},
"contexts": [],
"metadata": {
  "intentId": "39842aa0-53c4-4d47-b3b7-61ba0fc6d80c",
  "webhookUsed": "false",
  "webhookForSlotFillingUsed": "false",
  "intentName": "account.login"
},
"fulfillment": {
  "speech": "You should visit http://www.curlpad.com for login.",
  "messages": [
    {
      "type": "basic_card",
      "platform": "google",
      "title": "Login to Curlpad",
      "subtitle": "",
      "formattedText": "Visit this link to login to your account",
      "image": {
        "url": "http://www.curlpad.com/favicons/apple-icon.png"
      },
      "buttons": [
        {
          "title": "Curlpad",
          "openUrlAction": {
            "url": "http://www.curlpad.com"
          }
        }
      ]
    },
    {
      "type": 1,
      "platform": "telegram",
      "title": "Curlpad | Login",
      "subtitle": "Click on login button to continue",
      "imageUrl": "http://www.curlpad.com/favicons/apple-icon.png",
      "buttons": [
        {
          "text": "Login",
          "postback": "http://www.curlpad.com/"
        }
      ]
    },
    {
      "type": 0,
      "speech": "Open this url http://www.curlpad.com"
    }
  ]
},
"score": 1
  },
  "status": {
"code": 200,
"errorType": "success"
  },
  "sessionId": "7ba9cd11-239c-4467-8c3f-2d79d867ba18"
}```

The telegram card works fine on my telegram bot, but gives an error on Actions on Google.
Here is the response on Actions Simulator:

Other query works fine on that simulator.
Can anyone help to make this work?
I've one more intent to search user which works using webhook fulfillment, there also I'm getting the same problem while returning basic_card.

Screenshots of intent response with the try on api.ai:

答:
The problem was 'basic_card' is not supported without a 'basic response', so we need to set 'basic response' first or Use response from the DEFAULT tab as the first response.

Basic Response is Compulsory for basic_card

Body:
I'm building an app using Api.ai with where I need to respond to an Intent named Login by a basic card. I'm trying this without webhook fulfillment.
By Api.ai try section my query returns this:

{
  "id": "bb09aa94-a2d0-48d5-8c7f-62fc688d17b1",
  "timestamp": "2017-07-06T13:19:30.776Z",
  "lang": "en",
  "result": {
"source": "agent",
"resolvedQuery": "login",
"action": "Login",
"actionIncomplete": false,
"parameters": {},
"contexts": [],
"metadata": {
  "intentId": "39842aa0-53c4-4d47-b3b7-61ba0fc6d80c",
  "webhookUsed": "false",
  "webhookForSlotFillingUsed": "false",
  "intentName": "account.login"
},
"fulfillment": {
  "speech": "You should visit http://www.curlpad.com for login.",
  "messages": [
    {
      "type": "basic_card",
      "platform": "google",
      "title": "Login to Curlpad",
      "subtitle": "",
      "formattedText": "Visit this link to login to your account",
      "image": {
        "url": "http://www.curlpad.com/favicons/apple-icon.png"
      },
      "buttons": [
        {
          "title": "Curlpad",
          "openUrlAction": {
            "url": "http://www.curlpad.com"
          }
        }
      ]
    },
    {
      "type": 1,
      "platform": "telegram",
      "title": "Curlpad | Login",
      "subtitle": "Click on login button to continue",
      "imageUrl": "http://www.curlpad.com/favicons/apple-icon.png",
      "buttons": [
        {
          "text": "Login",
          "postback": "http://www.curlpad.com/"
        }
      ]
    },
    {
      "type": 0,
      "speech": "Open this url http://www.curlpad.com"
    }
  ]
},
"score": 1
  },
  "status": {
"code": 200,
"errorType": "success"
  },
  "sessionId": "7ba9cd11-239c-4467-8c3f-2d79d867ba18"
}

The telegram card works fine on my telegram bot, but gives an error on Actions on Google.
Here is the response on Actions Simulator:

Other query works fine on that simulator.
Can anyone help to make this work?
I've one more intent to search user which works using webhook fulfillment, there also I'm getting the same problem while returning basic_card.

Screenshots of intent response with the try on api.ai:


问:
Where can I find the primefaces tag library documentation?
Where can I find primefaces tag library documentation such as this: http://primefaces.prime.com.tr/docs/tag/index.html ?

I already have the jar, the sources of the primefaces. The apidoc supplied is "primefaces 2.2.RC2 API", not the "Tag Library Documentation Generator - Generated Documentation"

Maybe I should try generating it from the source, or maybe from the JAR (although I think the javadocs are not in the bytecodes) ?

答: if you need .tld file, you can find one in jar: in META-INF folder. It is called primefaces-i.tld</p>


问:
Can i send id value with javaScript textbox's value?
i want to find top value and left value using td id but i must take textbox value and i must send to find Help me please. </p>

```<code>   $(document).ready(function () {
    $("#button").click(function () {

        var _t1 = $("#t1").val();
        var _t2 = $("#t2").val();//users write values like 'A2' 'B8' here
        //alert("Values:" + _t1 + ' ' + _t2);

        $(document).ready(function () {
            var value = $("#B5"); //I need to send TextBox's value instead of
            writing like this
            var offset = value.offset();
            //alert("x : " + offset.top + " y : " + offset.left);

            <tr>
               <td>5</td>
                <td class="d" id="A5"></td>
                <td class="w" id="B5"></td>
                <td class="d" id="C5"></td>
                <td class="w" id="D5"></td>
                <td class="d" id="E5"></td>
                <td class="w" id="F5"></td>
                <td class="d" id="G5"></td>
                <td class="w" id="H5"></td>
            </tr>
</code>```

答:
Assuming that t2 is your textbox, you would want something like this:

var td = $('#' + $('#t2').val());

What this does is it appends the value of the textbox to the '#' character and then passes this concatenated string for jQuery as a selector.

Using the notations from above:

$(document).ready(function() {
  $("#button").click(function() {
    var inputtedID = $("#t2").val();
    if (inputtedID) {
      //check that it is not an empty string

      var td = $("#" + inputtedID);
      if (td.length > 0) {
        //if there is a td with that ID
        var offset = td.offset();
        $("#result").text("The offset for " + inputtedID + ": {top: " + offset.top + ", left: " + offset.left + "}");
      } else {
        $("#result").text("There is no element with id of " + inputtedID);
      }
    }
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>td{
  min-width: 10px;
  min-height: 10px;

}</code>```

    5

<input id="t2" />

<button id="button">Get Offset</button>

```

Body:
i want to find top value and left value using td id but i must take textbox value and i must send to find Help me please.

   $(document).ready(function () {
    $("#button").click(function () {

        var _t1 = $("#t1").val();
        var _t2 = $("#t2").val();//users write values like 'A2' 'B8' here
        //alert("Values:" + _t1 + ' ' + _t2);

        $(document).ready(function () {
            var value = $("#B5"); //I need to send TextBox's value instead of
            writing like this
            var offset = value.offset();
            //alert("x : " + offset.top + " y : " + offset.left);

               5

Body:
Assuming that t2 is your textbox, you would want something like this:

var td = $('#' + $('#t2').val());

What this does is it appends the value of the textbox to the '#' character and then passes this concatenated string for jQuery as a selector.

Using the notations from above:

$(document).ready(function() {
  $("#button").click(function() {
    var inputtedID = $("#t2").val();
    if (inputtedID) {
      //check that it is not an empty string

      var td = $("#" + inputtedID);
      if (td.length > 0) {
        //if there is a td with that ID
        var offset = td.offset();
        $("#result").text("The offset for " + inputtedID + ": {top: " + offset.top + ", left: " + offset.left + "}");
      } else {
        $("#result").text("There is no element with id of " + inputtedID);
      }
    }
  });
});

td{
  min-width: 10px;
  min-height: 10px;

}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr>
    <td>5</td>
    <td class="d" id="A5"></td>
    <td class="w" id="B5"></td>
    <td class="d" id="C5"></td>
    <td class="w" id="D5"></td>
    <td class="d" id="E5"></td>
    <td class="w" id="F5"></td>
    <td class="d" id="G5"></td>
    <td class="w" id="H5"></td>
  </tr>
</table>

<input id="t2" />

<button id="button">Get Offset</button>
<br>
<span id="result"></span>


问:
How to convert a Textview array list into a hashset?
Hey stackoverflow community,

i want to send an Arraylist of Textviews through shared Preferences to another Activity, so i tried to convert my list into a HashSet.

This is not accepted:

```<code>public List<TextView> FavDishes = new ArrayList<TextView>();
</code>```

.
.
.
FavDishes = new ArrayList<>();
            FavDishes.add(eingabe);

```<code>        **Set<String> taskSet = new HashSet<String>(FavDishes);**
        PreferenceManager.getDefaultSharedPreferences(context)
                .edit()
                .putStringSet("Data", taskSet)
                .apply();
</code>```

It tells me: "cannot resolve constructor HashSet on android widget Textview"

How would you solve this Problem?

Thanks for your time.

答:
Iterate over the FavDishes array to get the TextView values as string and store them to an array, then pass that array to your taskset instead of FavDishes.

Code will be something like:

```<code>List<TextView> FavDishes = new ArrayList<TextView>();
    FavDishes.add(fav1TV);
    FavDishes.add(fav2TV);
    FavDishes.add(fav3TV);

ArrayList<String> FavDishesString = new ArrayList<String>();

    for (TextView FavDish : FavDishes ){
        FavDishesString.add(FavDish.getText().toString());
    }

    Set<String> taskSet = new HashSet<String>(FavDishesString);
</code>```

Helpful link to ways to iterate arrayList:

https://crunchify.com/how-to-iterate-through-java-list-4-way-to-iterate-through-loop/

Body:
Hey stackoverflow community,

i want to send an Arraylist of Textviews through shared Preferences to another Activity, so i tried to convert my list into a HashSet.

This is not accepted:

public List<TextView> FavDishes = new ArrayList<TextView>();

.
.
.
FavDishes = new ArrayList<>();
            FavDishes.add(eingabe);

        **Set<String> taskSet = new HashSet<String>(FavDishes);**
        PreferenceManager.getDefaultSharedPreferences(context)
                .edit()
                .putStringSet("Data", taskSet)
                .apply();

It tells me: "cannot resolve constructor HashSet on android widget Textview"

How would you solve this Problem?

Thanks for your time.

Body:
Iterate over the FavDishes array to get the TextView values as string and store them to an array, then pass that array to your taskset instead of FavDishes.

Code will be something like:

List<TextView> FavDishes = new ArrayList<TextView>();
    FavDishes.add(fav1TV);
    FavDishes.add(fav2TV);
    FavDishes.add(fav3TV);

ArrayList<String> FavDishesString = new ArrayList<String>();

    for (TextView FavDish : FavDishes ){
        FavDishesString.add(FavDish.getText().toString());
    }

    Set<String> taskSet = new HashSet<String>(FavDishesString);

Helpful link to ways to iterate arrayList:

https://crunchify.com/how-to-iterate-through-java-list-4-way-to-iterate-through-loop/


答: It is not possible. You need an Apple developer account for certificates and profiles. Without these you can't test app on device. </p>

Title: Is it possible to send an iOS app to a client to test without an Apple Developer ID and iPhone device?

Body:
I'm working on an iOS app. Just now I've completed my app. I'm testing it in simulator. Now I want to send this app to a client to test.

I do not have an Apple developer account (paid) and neither does my client. Also I do not have an iPhone device. Is it possible to give my app to client without these? If yes, what is the process?


问:
Does windows 8 support Visual Source Safe?
Does windows 8 supports visual source safe (or the other way around?)

Aka, can you install visual source safe running windows 8?

答:
Yes, and in windows 10 too.
Copy and paste VSS from other computer in any folder in new computer.

For register in VB60 ide, execute SSINT.EXE
Find an run .EXE in VSS folder for other opcions