<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Form submitted in different Library</title><link>https://www.infopathdev.com:443/forums/thread/73141.aspx</link><pubDate>Wed, 21 Dec 2011 01:24:35 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:73141</guid><dc:creator>csaha</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/73141.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=73141</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Users can enter the name and other information in the webpart and the
 form launches, and is submtted to the library but I would like the user
 to use the same webpart but launch other forms. Is there a way this is 
possible without making the first process
 redundant in different pages. &lt;/p&gt;
&lt;pre&gt;using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace FindYourStudent.FindYourStudent
{
    [ToolboxItemAttribute(false)]
    public class FindYourStudent : WebPart
    {
        &lt;a href="http://en.wikipedia.org/wiki/Text_box" class="ml-smartlink" target="_blank"&gt;TextBox&lt;/a&gt; txtFirstName = new TextBox();
        &lt;a href="http://en.wikipedia.org/wiki/Text_box" class="ml-smartlink" target="_blank"&gt;TextBox&lt;/a&gt; txtLastName = new TextBox();
        TextBox txtMiddleName = new TextBox();
        TextBox txtZip = new TextBox();
        TextBox txtWebID = new TextBox();
        TextBox txtWebPassword = new TextBox();
        Button btnLocate = new Button();
        Label results = new Label();

        protected override void CreateChildControls()
        {
            //Build the controls in a table
            Table table = new Table();
            table.Rows.Add(Common.RowFromTextBox(&amp;quot;Student First Name:&amp;quot;, txtFirstName));
            table.Rows.Add(Common.RowFromTextBox(&amp;quot;Student Middle Name:&amp;quot;, txtMiddleName));
            table.Rows.Add(Common.RowFromTextBox(&amp;quot;Student Last Name:&amp;quot;, txtLastName));
            table.Rows.Add(Common.RowFromTextBox(&amp;quot;Student Zip:&amp;quot;, txtZip));
            table.Rows.Add(Common.RowFromTextBox(&amp;quot;Web ID:&amp;quot;, txtWebID));
            table.Rows.Add(Common.RowFromTextBox(&amp;quot;Web Password:&amp;quot;, txtWebPassword));
            table.Rows.Add(Common.RowWithAnyButton(&amp;quot;Click to locate student&amp;quot;, &amp;quot;Find Student&amp;quot;, btnLocate));
            table.Rows.Add(Common.RowWithLableSpan(results, 2, HorizontalAlign.Center));
            //Create the event handler
            btnLocate.Click += new EventHandler(btnLocate_Click);

            this.Controls.Add(table);
        }
        private void btnLocate_Click(object sender, EventArgs e)
        {
            //Validate The feilds are filled
            if (txtFirstName.Text.Length==0 )
            {
                results.Text = &amp;quot;Please enter First Name&amp;quot;;
                return;
            }
            if ( txtLastName.Text.Length == 0 )
            {
                results.Text = &amp;quot;Please enter Last Name&amp;quot;;
                return;
            }
            if ( txtZip.Text.Length == 0)
            {
                results.Text = &amp;quot;Please enter Zip-Code&amp;quot;;
                return;
            }
           
            //Get reference to the list &amp;quot;EnrolledStudents&amp;quot;  created from Power School Oracle query
            SPWeb web= SPContext.Current.Web;
            SPList list = web.Lists.TryGetList(&amp;quot;EnrolledStudents&amp;quot;);
            
            //Build a CAML query            
            SPQuery query = new SPQuery();
            string q =   &amp;quot;&amp;lt;Where&amp;gt;&amp;lt;Eq&amp;gt;&amp;quot;;
            q += &amp;quot;&amp;lt;FieldRef Name=&amp;#39;First_Name&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;Text&amp;#39;&amp;gt;&amp;quot;;
            q += txtFirstName.Text + &amp;quot;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;quot;;
            q += &amp;quot;&amp;lt;And&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Last_Name&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;Text&amp;#39;&amp;gt;&amp;quot;;
            q += txtLastName.Text + &amp;quot; &amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/And&amp;gt;&amp;quot;;
            q += &amp;quot;&amp;lt;And&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Middle_Name&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;Text&amp;#39;&amp;gt;&amp;quot;;
            q += txtMiddleName.Text + &amp;quot;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/And&amp;gt;&amp;quot;;
            q += &amp;quot;&amp;lt;And&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Zip&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;Text&amp;#39;&amp;gt;&amp;quot;;
            q += txtZip.Text + &amp;quot;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/And&amp;gt;&amp;quot;;
            q += &amp;quot;&amp;lt;And&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Web_ID&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;Text&amp;#39;&amp;gt;&amp;quot;;
            q += txtWebID.Text + &amp;quot;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/And&amp;gt;&amp;quot;;
            q += &amp;quot;&amp;lt;And&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name=&amp;#39;Web_Password&amp;#39; /&amp;gt;&amp;lt;Value Type=&amp;#39;Text&amp;#39;&amp;gt;&amp;quot;;
            q += txtWebPassword.Text + &amp;quot;&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/And&amp;gt;&amp;quot;;
            q += &amp;quot;&amp;lt;/Where&amp;gt;&amp;quot;;
            query.Query = q;
            SPListItemCollection  items = list.GetItems(query);
            if (items.Count &amp;gt; 0)
            {
                results.Text = &amp;quot;No one Found! Try at a later date&amp;quot;;
                &lt;a href="http://en.wikipedia.org/wiki/Foreach" class="ml-smartlink" target="_blank"&gt;foreach&lt;/a&gt; (SPListItem item in items)
                {
                    if ( FixNull( item,&amp;quot;First_Name&amp;quot;)==txtFirstName.Text &amp;amp;&amp;amp; FixNull(item,&amp;quot;Last_Name&amp;quot;)==txtLastName.Text
                       &amp;amp;&amp;amp; FixNull(item, &amp;quot;Middle_Name&amp;quot;) == txtMiddleName.Text &amp;amp;&amp;amp; FixNull(item, &amp;quot;Zip&amp;quot;) == txtZip.Text &amp;amp;&amp;amp; FixNull(item, &amp;quot;Web_ID&amp;quot;) == txtWebID.Text &amp;amp;&amp;amp; FixNull(item, &amp;quot;Web_Password&amp;quot;) == txtWebPassword.Text)
                    {
                        // System.Diagnostics.Debug.WriteLine(item.Title);
                        string href = &amp;quot;&amp;lt;A href=&amp;#39;/SL/SitePages/ParentsPermissions.aspx?studentID=&amp;quot; + item[&amp;quot;Student_Number&amp;quot;].ToString() + &amp;quot;&amp;#39;&amp;gt;&amp;quot;;
                        results.Text = href + &amp;quot;Found in class of &amp;quot; + item[&amp;quot;ClassOf&amp;quot;].ToString() + &amp;quot; student &amp;quot; + item.Title + &amp;quot; Number: &amp;quot; + item[&amp;quot;Student_Number&amp;quot;].ToString() + &amp;quot;&amp;lt;/A&amp;gt;&amp;quot;;
                        break;
                    }
                }
            }
            else
            {
                results.Text = &amp;quot;No one Found! Try at a later date&amp;quot;;
            }
           // web.Dispose();
        }&lt;/pre&gt;</description></item></channel></rss>