Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing method button from masterpage and use onclick event on child
    primarykey
    data
    text
    <h1>Problem 1</h1> <p>I'm trying to use an Onclick event from a search button, that is located on the master page, in a child page. I found a good solution on this site but it doesn't work. </p> <p>Link to it: <a href="https://stackoverflow.com/questions/5687134/how-to-handle-master-page-button-event-in-content-page">How to handle master page button event in content page?</a></p> <p>The difference with that solution is that my IpageInterface is located in the App_Code folder and is in the namespace Business.</p> <p>Other then that it's pretty much the same.</p> <p>So I have the IpageInterface class:</p> <pre><code>namespace Business { public interface IpageInterface { void DoSomeAction(); } } </code></pre> <p>Then on my master page I have:</p> <pre><code>using Business; public partial class site : System.Web.UI.MasterPage { protected void SearchQuery_Click(object sender, EventArgs e) { IpageInterface pageInterface = Page as IpageInterface; if (pageInterface != null) { pageInterface.DoSomeAction(); } } } </code></pre> <p>And finally I have, on the page I want to use it (results page, because the button is a search button):</p> <pre><code>using Business; public partial class results : System.Web.UI.Page, IpageInterface { public void DoSomeAction() { ContentPlaceHolder mainContent = (ContentPlaceHolder)Master.FindControl("mainContent"); if (mainContent != null) { DropDownList ddlSearchOn = (DropDownList)mainContent.FindControl("ddlSearchOn"); TextBox TxtSearch = (TextBox)mainContent.FindControl("TxtSearch"); if (ddlSearchOn.Text == "Everything" || ddlSearchOn.Text == "Title" || ddlSearchOn.Text == "Text") { List&lt;News&gt; newsSearchResults = News.SearchNews(ddlSearchOn.Text, TxtSearch.Text); foreach(News newsArticle in newsSearchResults) { newsArticle.Text = LimitCharacters(newsArticle.Text, 350); } repeaterSearchResults.DataSource = newsSearchResults; repeaterSearchResults.DataBind(); } } } </code></pre> <p>But when I press the button, and I look at the value of pageInterface it says it's null.</p> <h1>Problem 2</h1> <p><strong>EDIT:</strong> Problem 2 is solved. I selected 'Cascade' next to the delete rule in Foreign Key relationships window.</p> <p>Besides that problem I have a second problem with MS SQL which goes as follows: I have news articles with comments, when I want to remove the article I have to remove the comments as well, so I use the following query:</p> <pre><code>SqlCommand cmd = new SqlCommand(@"DELETE FROM News_comments WHERE News_comments.news_Id = @news_Id AND News_comments.account_Id = @account_Id; DELETE FROM News_news WHERE News_news.news_Id = @news_Id" , conn); </code></pre> <p>The problem is though, that it still seems to thing that the article still has comments, eventhough the comments are removed. So I can't remove the article. The exception is:</p> <pre><code>"The DELETE statement conflicted with the REFERENCE constraint" exception. </code></pre> <p>Would appreciate the needed help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload